home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / bit / listserv / statl / 2418 < prev    next >
Encoding:
Text File  |  1993-01-21  |  1.8 KB  |  51 lines

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