home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / bit / listserv / sasl / 5495 < prev    next >
Encoding:
Text File  |  1992-12-31  |  7.3 KB  |  182 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!paladin.american.edu!auvm!UNC.BITNET!UNCSM1
  3. Message-ID: <SAS-L%92123114230334@VTVM2.CC.VT.EDU>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Thu, 31 Dec 1992 14:24:00 EST
  6. Reply-To:     Sally Muller <UNCSM1@UNC.BITNET>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Sally Muller <UNCSM1@UNC.BITNET>
  9. Subject:      Data manipulation question
  10. Lines: 170
  11.  
  12. ----------------------------------------------------------------------
  13. CONTENT:  Question
  14. SUMMARY:  Question data manipulation needs to compute new variable
  15. REL/PLTF: 6.07 MVS/ESA
  16. E-ADDR:   uncsm1@unc.bitnet
  17. NAME:     Sally Muller
  18. PH/ADDR:  919-962-6501  OIT CB#3455, UNC, Chapel Hill NC 27514
  19. ----------------------------------------------------------------------
  20. This is my last question for the year.....unless I connect using
  21. Delphi!  A question from a user trying to finish big D.
  22. Happy holidays y'all!
  23. Sally
  24.  
  25.  HI!
  26.      HERE IS THE PROBLEM THAT I BROUGHT TO YOU THIS MORNING.
  27.  
  28.  MY DATA SAS DATASET HAS 9112 OBSERVATIONS AND FOUR VARIABLES.  SHOWN
  29.  BELOW IS PART OF THE DATA (49 OBSVERVATIONS).
  30.  
  31. OBS    COCD      PR80     SIC80    ENTSIC
  32.  
  33.   1     A2     0.00085    2751      2761
  34.   2     A2     0.00141    2753      5112
  35.   3     A2     0.02359    3079      7372
  36.   4     A2     0.07601    3555         .
  37.   5     A2     0.09014    3573         .
  38.   6     A2     0.15923    3579         .
  39.   7     A2     0.00212    3643         .
  40.   8     A2     0.01201    3811         .
  41.   9     A2     0.19045    3861         .
  42.  10     A2     0.02331    3955         .
  43.  11     A2     0.33216    5081         .
  44.  12     A2     0.02119    5084         .
  45.  13     A2     0.02232    5086         .
  46.  14     A2     0.02812    5113         .
  47.  15     A2     0.00848    5943         .
  48.  16     A2     0.00085    6371         .
  49.  17     A2     0.00381    7333         .
  50.  18     A2     0.00396    7699         .
  51.  19     A3     0.00039    0191      1213
  52.  20     A3     0.00086    1021      2816
  53.  21     A3     0.01108    1031      4013
  54.  22     A3     0.12523    1061      4463
  55.  23     A3     0.00035    1081      4723
  56.  24     A3     0.24670    1211      5051
  57.  25     A3     0.05925    1311      5052
  58.  26     A3     0.00580    1382      5094
  59.  27     A3     0.00630    1474      5172
  60.  28     A3     0.01844    1475      5191
  61.  29     A3     0.00646    2491      6793
  62.  30     A3     0.03732    2819      8911
  63.  31     A3     0.04738    2874         .
  64.  32     A3     0.00697    3274         .
  65.  33     A3     0.00031    3295         .
  66.  34     A3     0.00360    3297         .
  67.  35     A3     0.01230    3313         .
  68.  36     A3     0.10526    3331         .
  69.  37     A3     0.13130    3333         .
  70.  38     A3     0.01609    3339         .
  71.  39     A3     0.05098    3341         .
  72.  40     A3     0.04773    3356         .
  73.  41     A3     0.00513    3357         .
  74.  42     A3     0.00047    3471         .
  75.  43     A3     0.00168    4011         .
  76.  44     A3     0.00435    5084         .
  77.  45     A3     0.02561    5161         .
  78.  46     A3     0.00027    6371         .
  79.  47     A3     0.01222    6711         .
  80.  48     A3     0.00955    7391         .
  81.  49     A3     0.00059    7397         .
  82.  
  83.  I WANT TO DO THE FOLLOWING MANIPULATIONS ON IT:
  84.  
  85. (reworded a little)
  86.  
  87. 1. CREATE A VARIABLE CALLED 'D'.  COCD is the "by variable" and
  88.    he wants to compute D from an operation on SIC80 and ENTSIC.
  89.    The trick being he wants each SIC80 with each ENTSIC within
  90.    a particular COCD.  For example for the first COCD ('A2') he
  91.    wants to output 18*3=54   observations which will have the D
  92.    variable.  Similarly, for the second COCD ('A3') he needs
  93.    31*12=372 observations output.
  94.  
  95. The good ol' fashioned way is with arrays and do-loops --
  96. however, this is a little more complicated because for each COCD
  97. the number of obs output will vary since the number of values for
  98. SIC80 and ENTSIC varies.  Its my New Year resolution to use SQL
  99. but I've got nine days left...
  100. :-)....any suggestions much appreciated!!
  101.  
  102. 2. Other stuff user included that isn't necessary for solution to
  103.    above problem.
  104.  
  105.  /*     -----------------  CUT  HERE   ---------------------------------
  106.    THE RULE USED TO OBTAIN THE VALUES FOR 'D' IS AS FOLLOWS:
  107.    IF SUBSTR(SI80,1,3)=SUBSTR(ENTSIC,1,3) THEN D=0;
  108.    IF SUBSTR(SI80,1,2)=SUBSTR(ENTSIC,1,2) THEN D=1;
  109.    ELSE D=2;
  110.  
  111.    IN ESSENCE, THEN, FOR EACH VALUE OF ENTSIC WITHIN A GIVEN COCD,
  112.    THE NUMBER OF OBSERVATIONS FOR 'D' WILL BE EQUAL TO THE NUMBER OF
  113.    OBSERVATIONS FOR THAT COCD.  FOR EXAMPLE, SINCE THERE ARE 18
  114.    OBSERVATIONS UNDER COCD='A2', THERE WILL BE 18 OSERVATIONS EACH
  115.    FOR ENTSIC=2751, ENTSIC=5112, AND ENTSIC=7372.
  116.  
  117.    THEN FOR EACH COCD-ENTSIC PAIR, I NEED TO MULTIPLY 'D' WITH EACH OF
  118.    THE OBSERVATIONS IN PR80.  THIS WILL YIELD, FOR COCD-ENTSIC = A2-2751,
  119.    18 OBSERVATIONS FOR A NEW VARIABLE CALLED VAR1.  SIMILARLY THERE WILL
  120.    BE 18 OBSERVATIONS EACH FOR THE OTHER TWO COCD-ENTSIC PAIR WITHIN
  121.    COCD='A2' (A2-5112, A2-7372).
  122.  
  123.    FINALLY, ALL THE OBSERVATIONS UNDER EACH COCD-ENTSIC ARE SUMMED TO
  124.    OBTAIN A NEW VARIABLE CALLED 'PREL'.  THAT IS, THERE WILL BE ONE
  125.    OBSERVATION FOR 'PREL' FOR EACH COCD-ENTSIC PAIR.
  126.  
  127. IN EFFECT, THE FINAL DATA SHOULD LOOK AS FOLLOWS:
  128.  
  129. OBS    COCD      PR80     SIC80    ENTSIC    PREL
  130.  
  131.   1     A2     0.00085    2751      2761     VALUE
  132.   2     A2     0.00141    2753      5112     VALUE
  133.   3     A2     0.02359    3079      7372     VALUE
  134.   4     A2     0.07601    3555         .
  135.   5     A2     0.09014    3573         .
  136.   6     A2     0.15923    3579         .
  137.   7     A2     0.00212    3643         .
  138.   8     A2     0.01201    3811         .
  139.   9     A2     0.19045    3861         .
  140.  10     A2     0.02331    3955         .
  141.  11     A2     0.33216    5081         .
  142.  12     A2     0.02119    5084         .
  143.  13     A2     0.02232    5086         .
  144.  14     A2     0.02812    5113         .
  145.  15     A2     0.00848    5943         .
  146.  16     A2     0.00085    6371         .
  147.  17     A2     0.00381    7333         .
  148.  18     A2     0.00396    7699         .
  149.  19     A3     0.00039    0191      1213     VALUE
  150.  20     A3     0.00086    1021      2816     VALUE
  151.  21     A3     0.01108    1031      4013     VALUE
  152.  22     A3     0.12523    1061      4463     VALUE
  153.  23     A3     0.00035    1081      4723     VALUE
  154.  24     A3     0.24670    1211      5051     VALUE
  155.  25     A3     0.05925    1311      5052     VALUE
  156.  26     A3     0.00580    1382      5094     VALUE
  157.  27     A3     0.00630    1474      5172     VALUE
  158.  28     A3     0.01844    1475      5191     VALUE
  159.  29     A3     0.00646    2491      6793     VALUE
  160.  30     A3     0.03732    2819      8911     VALUE
  161.  31     A3     0.04738    2874         .
  162.  32     A3     0.00697    3274         .
  163.  33     A3     0.00031    3295         .
  164.  34     A3     0.00360    3297         .
  165.  35     A3     0.01230    3313         .
  166.  36     A3     0.10526    3331         .
  167.  37     A3     0.13130    3333         .
  168.  38     A3     0.01609    3339         .
  169.  39     A3     0.05098    3341         .
  170.  40     A3     0.04773    3356         .
  171.  41     A3     0.00513    3357         .
  172.  42     A3     0.00047    3471         .
  173.  43     A3     0.00168    4011         .
  174.  44     A3     0.00435    5084         .
  175.  45     A3     0.02561    5161         .
  176.  46     A3     0.00027    6371         .
  177.  47     A3     0.01222    6711         .
  178.  48     A3     0.00955    7391         .
  179.  49     A3     0.00059    7397         .
  180.  
  181. THANKS FOR YOU HELP.
  182.