home *** CD-ROM | disk | FTP | other *** search
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Path: sparky!uunet!paladin.american.edu!auvm!UNC.BITNET!UNCSM1
- Message-ID: <SAS-L%92123114230334@VTVM2.CC.VT.EDU>
- Newsgroups: bit.listserv.sas-l
- Date: Thu, 31 Dec 1992 14:24:00 EST
- Reply-To: Sally Muller <UNCSM1@UNC.BITNET>
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- From: Sally Muller <UNCSM1@UNC.BITNET>
- Subject: Data manipulation question
- Lines: 170
-
- ----------------------------------------------------------------------
- CONTENT: Question
- SUMMARY: Question data manipulation needs to compute new variable
- REL/PLTF: 6.07 MVS/ESA
- E-ADDR: uncsm1@unc.bitnet
- NAME: Sally Muller
- PH/ADDR: 919-962-6501 OIT CB#3455, UNC, Chapel Hill NC 27514
- ----------------------------------------------------------------------
- This is my last question for the year.....unless I connect using
- Delphi! A question from a user trying to finish big D.
- Happy holidays y'all!
- Sally
-
- HI!
- HERE IS THE PROBLEM THAT I BROUGHT TO YOU THIS MORNING.
-
- MY DATA SAS DATASET HAS 9112 OBSERVATIONS AND FOUR VARIABLES. SHOWN
- BELOW IS PART OF THE DATA (49 OBSVERVATIONS).
-
- OBS COCD PR80 SIC80 ENTSIC
-
- 1 A2 0.00085 2751 2761
- 2 A2 0.00141 2753 5112
- 3 A2 0.02359 3079 7372
- 4 A2 0.07601 3555 .
- 5 A2 0.09014 3573 .
- 6 A2 0.15923 3579 .
- 7 A2 0.00212 3643 .
- 8 A2 0.01201 3811 .
- 9 A2 0.19045 3861 .
- 10 A2 0.02331 3955 .
- 11 A2 0.33216 5081 .
- 12 A2 0.02119 5084 .
- 13 A2 0.02232 5086 .
- 14 A2 0.02812 5113 .
- 15 A2 0.00848 5943 .
- 16 A2 0.00085 6371 .
- 17 A2 0.00381 7333 .
- 18 A2 0.00396 7699 .
- 19 A3 0.00039 0191 1213
- 20 A3 0.00086 1021 2816
- 21 A3 0.01108 1031 4013
- 22 A3 0.12523 1061 4463
- 23 A3 0.00035 1081 4723
- 24 A3 0.24670 1211 5051
- 25 A3 0.05925 1311 5052
- 26 A3 0.00580 1382 5094
- 27 A3 0.00630 1474 5172
- 28 A3 0.01844 1475 5191
- 29 A3 0.00646 2491 6793
- 30 A3 0.03732 2819 8911
- 31 A3 0.04738 2874 .
- 32 A3 0.00697 3274 .
- 33 A3 0.00031 3295 .
- 34 A3 0.00360 3297 .
- 35 A3 0.01230 3313 .
- 36 A3 0.10526 3331 .
- 37 A3 0.13130 3333 .
- 38 A3 0.01609 3339 .
- 39 A3 0.05098 3341 .
- 40 A3 0.04773 3356 .
- 41 A3 0.00513 3357 .
- 42 A3 0.00047 3471 .
- 43 A3 0.00168 4011 .
- 44 A3 0.00435 5084 .
- 45 A3 0.02561 5161 .
- 46 A3 0.00027 6371 .
- 47 A3 0.01222 6711 .
- 48 A3 0.00955 7391 .
- 49 A3 0.00059 7397 .
-
- I WANT TO DO THE FOLLOWING MANIPULATIONS ON IT:
-
- (reworded a little)
-
- 1. CREATE A VARIABLE CALLED 'D'. COCD is the "by variable" and
- he wants to compute D from an operation on SIC80 and ENTSIC.
- The trick being he wants each SIC80 with each ENTSIC within
- a particular COCD. For example for the first COCD ('A2') he
- wants to output 18*3=54 observations which will have the D
- variable. Similarly, for the second COCD ('A3') he needs
- 31*12=372 observations output.
-
- The good ol' fashioned way is with arrays and do-loops --
- however, this is a little more complicated because for each COCD
- the number of obs output will vary since the number of values for
- SIC80 and ENTSIC varies. Its my New Year resolution to use SQL
- but I've got nine days left...
- :-)....any suggestions much appreciated!!
-
- 2. Other stuff user included that isn't necessary for solution to
- above problem.
-
- /* ----------------- CUT HERE ---------------------------------
- THE RULE USED TO OBTAIN THE VALUES FOR 'D' IS AS FOLLOWS:
- IF SUBSTR(SI80,1,3)=SUBSTR(ENTSIC,1,3) THEN D=0;
- IF SUBSTR(SI80,1,2)=SUBSTR(ENTSIC,1,2) THEN D=1;
- ELSE D=2;
-
- IN ESSENCE, THEN, FOR EACH VALUE OF ENTSIC WITHIN A GIVEN COCD,
- THE NUMBER OF OBSERVATIONS FOR 'D' WILL BE EQUAL TO THE NUMBER OF
- OBSERVATIONS FOR THAT COCD. FOR EXAMPLE, SINCE THERE ARE 18
- OBSERVATIONS UNDER COCD='A2', THERE WILL BE 18 OSERVATIONS EACH
- FOR ENTSIC=2751, ENTSIC=5112, AND ENTSIC=7372.
-
- THEN FOR EACH COCD-ENTSIC PAIR, I NEED TO MULTIPLY 'D' WITH EACH OF
- THE OBSERVATIONS IN PR80. THIS WILL YIELD, FOR COCD-ENTSIC = A2-2751,
- 18 OBSERVATIONS FOR A NEW VARIABLE CALLED VAR1. SIMILARLY THERE WILL
- BE 18 OBSERVATIONS EACH FOR THE OTHER TWO COCD-ENTSIC PAIR WITHIN
- COCD='A2' (A2-5112, A2-7372).
-
- FINALLY, ALL THE OBSERVATIONS UNDER EACH COCD-ENTSIC ARE SUMMED TO
- OBTAIN A NEW VARIABLE CALLED 'PREL'. THAT IS, THERE WILL BE ONE
- OBSERVATION FOR 'PREL' FOR EACH COCD-ENTSIC PAIR.
-
- IN EFFECT, THE FINAL DATA SHOULD LOOK AS FOLLOWS:
-
- OBS COCD PR80 SIC80 ENTSIC PREL
-
- 1 A2 0.00085 2751 2761 VALUE
- 2 A2 0.00141 2753 5112 VALUE
- 3 A2 0.02359 3079 7372 VALUE
- 4 A2 0.07601 3555 .
- 5 A2 0.09014 3573 .
- 6 A2 0.15923 3579 .
- 7 A2 0.00212 3643 .
- 8 A2 0.01201 3811 .
- 9 A2 0.19045 3861 .
- 10 A2 0.02331 3955 .
- 11 A2 0.33216 5081 .
- 12 A2 0.02119 5084 .
- 13 A2 0.02232 5086 .
- 14 A2 0.02812 5113 .
- 15 A2 0.00848 5943 .
- 16 A2 0.00085 6371 .
- 17 A2 0.00381 7333 .
- 18 A2 0.00396 7699 .
- 19 A3 0.00039 0191 1213 VALUE
- 20 A3 0.00086 1021 2816 VALUE
- 21 A3 0.01108 1031 4013 VALUE
- 22 A3 0.12523 1061 4463 VALUE
- 23 A3 0.00035 1081 4723 VALUE
- 24 A3 0.24670 1211 5051 VALUE
- 25 A3 0.05925 1311 5052 VALUE
- 26 A3 0.00580 1382 5094 VALUE
- 27 A3 0.00630 1474 5172 VALUE
- 28 A3 0.01844 1475 5191 VALUE
- 29 A3 0.00646 2491 6793 VALUE
- 30 A3 0.03732 2819 8911 VALUE
- 31 A3 0.04738 2874 .
- 32 A3 0.00697 3274 .
- 33 A3 0.00031 3295 .
- 34 A3 0.00360 3297 .
- 35 A3 0.01230 3313 .
- 36 A3 0.10526 3331 .
- 37 A3 0.13130 3333 .
- 38 A3 0.01609 3339 .
- 39 A3 0.05098 3341 .
- 40 A3 0.04773 3356 .
- 41 A3 0.00513 3357 .
- 42 A3 0.00047 3471 .
- 43 A3 0.00168 4011 .
- 44 A3 0.00435 5084 .
- 45 A3 0.02561 5161 .
- 46 A3 0.00027 6371 .
- 47 A3 0.01222 6711 .
- 48 A3 0.00955 7391 .
- 49 A3 0.00059 7397 .
-
- THANKS FOR YOU HELP.
-