home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!UNC.BITNET!UPHILG
- Return-Path: <@OHSTVMA.ACS.OHIO-STATE.EDU:SAS-L@VTVM2.BITNET>
- Message-ID: <SAS-L%93012114384991@VTVM2.CC.VT.EDU>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 21 Jan 1993 14:39:00 EST
- Reply-To: "Philip Gallagher,(919)966-1065" <UPHILG@UNC.BITNET>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: "Philip Gallagher,(919)966-1065" <UPHILG@UNC.BITNET>
- Subject: reflections on: How to skip variables in SAS
- Lines: 58
-
- Andrew Karp provided a neat answer for Haiyi Xie's problem of selecting
- just a few variables from a raw data file which will be converted into few
- a SAS data set in subequent data analyses, namely:
- for
- 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;
-
- Being unable to resist being my usual picky self, I point out
- that the following will work as well:
-
- DATA CLASS(KEEP=POP71 POP75-POP77 POP85);
- INFILE SOC631.DAT LRECL=320;
- INPUT #2 (POP70-POP85) (16*20.)
- #12 ;
- RUN;
-
- The #n tells SAS to move a pointer to line n; SAS takes the
- largest value of n to appear in the INPUT stmnt to be the number of
- of lines per case. In addition, within the n records for a case
- one may move the pointer backward and forward at will, as long as
- the #n (where n is the number of records per case) appears
- somewhere in the stmnt.
-
- Therefore the following works, too:
-
- DATA CLASS(KEEP=POP71 POP75-POP77 POP85);
- INFILE SOC631.DAT LRECL=320;
- INPUT #12 #2 (POP70-POP85) (16*20.);
- RUN;
-
- In principle (al?) this code should be trivially more efficient
- than the original code, for moving the pointer 12 times must take
- a little longer than moving it 2 times - but I would be amazed
- if the savings would be noticeable for anything but a truly
- enormous dataset. Thus my suggestion is really only trivially
- different from Andrew's. My hope is that it spotlights the
- mechanism a little better, that's all.
-
-
- I imagine Andrew knows all this and didn't want to unnecessarily
- complicate a reply to a beginner (makes sense to me!), but, as I
- said, I couldn't resist, and Haiyi Xie already has Andrew's
- uncomplicated answer.
-
- Phil Gallagher
-