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