home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / bit / listserv / sasl / 3457 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.6 KB  |  73 lines

  1. Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
  2. Path: sparky!uunet!gatech!paladin.american.edu!auvm!COMPUSERVE.COM!76350.1604
  3. Message-ID: <920728205220_76350.1604_EHJ26-1@CompuServe.COM>
  4. Newsgroups: bit.listserv.sas-l
  5. Date:         Tue, 28 Jul 1992 16:52:20 EDT
  6. Reply-To:     Andy Norton <76350.1604@COMPUSERVE.COM>
  7. Sender:       "SAS(r) Discussion" <SAS-L@UGA.BITNET>
  8. From:         Andy Norton <76350.1604@COMPUSERVE.COM>
  9. Subject:      writing variable names to external file
  10. Comments: To: SAS-L <SAS-L@AWIIMC12.IMC.UNIVIE.AC.AT>
  11. Lines: 60
  12.  
  13. From:      Andy Norton    (616) 344-2191   76350.1604@compuserve.com
  14. Address:   Trilogy Consulting, 5228 Lovers Lane, Kalamazoo MI 49002
  15. Rel/Pltf:  6.07 CMS
  16. Re:        Response to Steve Wickham
  17.            "Writing variable names to an external file"
  18.  
  19. Steve Wickham (SWICKHAM%DARTCMS1.BITNET) writes
  20. >  I have a transposed data set that I'd like to write to an external
  21. >  file, with variable names at the top of columns.  Put 'var1'
  22. >  'var2', etc. where var1 is the 1st variable name, etc. won't work
  23. > because I don't exactly know the names of the variables
  24. > due to the transpose.  The transposed variables all have the same
  25. > prefix, but they also have a number that ranges between 0 - 99, but
  26. > not consecutively.
  27. >   Confused? An example:
  28. > DATE RIVER SITE ORDER1 ORDER3 ORDER5 ORDER17 ORDER9 ORDER85
  29. > I need to output these column headings along with their values
  30. > without knowing their names beforehand.  Any ideas?
  31.  
  32. Try the following:
  33.  
  34.    data _null_;
  35.      set TRANSPOS;
  36.      array ORDER {*} ORDER: ;
  37.      if _N_ eq 1 then
  38.         do;
  39.         length NAME $ 8;
  40.         do I = 1 to dim(ORDER);
  41.            call vname(V{I}, NAME);
  42.            put NAME $8.-r +2 @;
  43.            end;
  44.         put;
  45.         end;
  46.      do I = 1 to dim(ORDER);
  47.         put V{I} 8. +2 @;
  48.         end;
  49.      put;
  50. run;
  51.  
  52. --------------
  53. Note 1:
  54.    ORDER: refers to all variables beginning with "ORDER".  I think
  55. these "prefix variable lists" will work on your VMS system.  They work
  56. on CMS 6.07.  They are mentioned in print on page 1205 of the Version 5
  57. manual, and in SAS Usage note V5-SYS.COMP-0630.  In other words, use at
  58. your own risk.  If you don't want to use them, you can list all the
  59. variables here.
  60.  
  61. Note 2:
  62.    CALL VNAME is documented on page 634 of the version 6 Language
  63. Reference.  The variable name from the first argument is placed into
  64. the second argument.  The length of the second argument (NAME) should
  65. be explicitly declared.
  66.  
  67. Note 3:
  68.    $8.-r
  69.    This right-justifies the names so that they line up with the
  70. numbers.  See page 462 of version 6 Language Reference.
  71.  
  72.                                   Andy
  73.