home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!CTS27.CS.PGE.COM!AHK3
- Message-ID: <9301211754.AA11480@csd01.cs.pge.com>
- Newsgroups: bit.listserv.stat-l
- Date: Thu, 21 Jan 1993 09:45:22 PST
- Sender: STATISTICAL CONSULTING <STAT-L@MCGILL1.BITNET>
- From: AHK3%MR%MCS@CTS27.CS.PGE.COM
- Subject: re: How to skip variables in SAS
- Lines: 40
-
- Haiyi Xie (FREUD.SAS.UTAH.EDU) asked for a short cut in selecting just a few
- variables from a raw data file which will converted in to a SAS data set for
- susequent data analyses.
-
- Haiyi's problem is that there are twelve lines of raw data per observation,
- and a total of 177 variables, from which only four or five are to be included
- in the SAS data set. As it turns out, the desired variables are all on the
- same line of raw data.
-
- The quickest way to solve the problem is the following SAS data step:
-
- DATA CLASS(KEEP=POP71 POP75-POP77 POP85);
- INFILE SOC631.DAT LRECL=320;
- INPUT #1
- #2 (POP70-POP85) (16*20.)
- #3
- #4
- #5
- #6
- #7
- #8
- #9
- #10
- #11
- #12 ;
- RUN;
-
- This data step will only read the variables in the second line of raw data,
- and force the pointer to skip the rest of the lines of raw data. The KEEP
- statement tells SAS to keep only the variables POP71, POP75, POP76 and POP85
- in the output SAS data set.
-
- Haiyi should see a significant reduction in data step processing time and
- memory requirements as only one line of the raw data is read through the SAS
- program data vector and, subsequently, only four variables are included in the
- SAS data set.
-
- Andrew Karp
- Pacific Gas & Electric Company
- AHK3 @DBU.PGE.COM
-