home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!gatech!paladin.american.edu!auvm!NIHCU.BITNET!HIS
- Message-ID: <SAS-L%92072216442546@UGA.CC.UGA.EDU>
- Newsgroups: bit.listserv.sas-l
- Date: Wed, 22 Jul 1992 16:44:29 EDT
- Reply-To: Howard Schreier <HIS@NIHCU.BITNET>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Howard Schreier <HIS@NIHCU.BITNET>
- Subject: RE: multiple identical id vars problem
- Lines: 55
-
- CONTENT: Comment on "multiple identical id vars problem"
- SUMMARY: Re-shaping data set with series of PROC TRANSPOSEs
- REL/PLTF: 6.04/ PC DOS
-
- From Kernon Gibes (gibes@swirl.monsanto.com):
-
- > Ed Silverman wrote that he wanted to re-organize:
- >
- > ID CODE TERM DATE
- >
- > 002162706 292 901 900309
- > 002162706 292 901 900403
- > 002254401 299 891 890201
- > 002254401 299 901 900303
- > 002254401 276 901 900405
- >
- > into (one observation per ID, multiple variables):
- >
- > ID CODE TERM DATE CODE2 TERM2 DATE2 CODE3 TERM3 DATE3
- >
- > 002162706 292 901 900309 299* 901 900403
- > 002254401 299 891 890201 299 901 900303 299** 901 900405
- >
- > (I'm assuming that 299* should be 292 and 299** should be 276??????)
- >
- > Since this is 6.04 he can't use SQL [ha ha ;-) ].
-
- Actually, the target shape of the data set (repeating groups of
- parallel variables) is alien to the relational approach to data
- management and therefore SQL does not lend itself. Note that SQL does
- not have arrays and that repetitive processing is something that
- happens over like *rows*, not columns.
-
- > This could be done easily enough in a data step with arrays and LAST.
- > processing, but since it's not clear that we know in advance the
- > maximum number of unique ID values, I've given one approach using PROC
- > TRANSPOSEs below. This doesn't give the desired order of variables and
- > missing values might present problems, but I'll leave the data step
- > approach to someone else!
-
- Maybe there is a role for SQL! Under 6.06+, I think a fairly simple
- query *could* determine the maximum number of unique ID values and
- stick it into a macro variable, so that a DATA step approach could be
- generalized. However, the series of TRANSPOSEs is the approach which
- thought of first when I saw this problem, and is what I would use
- under any version.
-
- [Kernon's code deleted]
-
- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
- \ Howard Schreier, U.S. Dept. of Commerce, Washington /
- / MVS 5.18 & 6.07 \
- \ Voice: (202) 377-4180 BITNET: HIS@NIHCU /
- / Fax: (202) 377-4614 INTERNET: HIS@CU.NIH.GOV \
- \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
-