home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!bu.edu!olivea!sgigate!sgiblab!swrinde!zaphod.mps.ohio-state.edu!howland.reston.ans.net!paladin.american.edu!auvm!CCM.HF.INTEL.COM!THOMAS_M_SKINNER
- From: Thomas_M_Skinner@CCM.HF.INTEL.COM (Thomas M Skinner)
- Newsgroups: bit.listserv.sas-l
- Subject: Re: Reordering variables in a SAS dataset
- Message-ID: <930126091340_4@ccm.hf.intel.com>
- Date: 26 Jan 93 17:13:40 GMT
- Sender: "SAS(r) Discussion" <SAS-L@UGA.BITNET>
- Reply-To: Thomas M Skinner <Thomas_M_Skinner@CCM.HF.INTEL.COM>
- Lines: 46
- Comments: Gated by NETNEWS@AUVM.AMERICAN.EDU
- Comments: To: SAS-L@uga.cc.uga.edu
-
-
- Folsom, California
- January 26, 1993
- Sunny, Bit of Frost
-
-
- Dear SAS-Lers,
-
- Theodore N. Greenstein Writes:
-
- >Is there an easy way to reorder the variables in a SAS dataset (this
- >is under 6.08 for Windows)? I know that I can (a) change the order
- >write the variables out using a PUT statement, then read them back
- >in the desired order. But isn't there some easier way?
- >
- >Just for comparison, I notice that SPSS/PC has a command that will do
- >exactly this: reorder the variables in any desired ordering.
- >
-
- The best way I can think of is to simply "declare" the variables in a
- length statement in the order you wish. At the beginning of the data step,
- the "program data vector" is set up in memory by first scanning for
- non-executable statements (of which length is one), and then the
- executables, such as the "set" statement. The non-executable statements are
- used to assign slots in the vector, then variables from the input, set,
- assignment statements, etc are assigned. Thus the length statement can be
- used on either datasets derived via "input" statements or by set/merge
- statements to determing the order of the vsriables in the resulting
- dataset.
-
- You may also use the "ATTRIB" statement to accomplish the same thing, and
- it gives you the ability to assign lables, informats, formats, as well as
- lengths.
-
- I believe the KEEP statement, and the "KEEP=" option the DATA statement
- will accomplish the same thing, without having to specify lengths, etc...
- Program efficiency is gained from limiting lengths to specified minimums
- however, so using the length statement is desirable from that standpoint.
-
- Intel-Insider,
- Tom Skinner
- ===========================================================================
- T.M. Skinner Internet: Thomas_M_Skinner@ccm.hf.intel.com
- Sr. SAS Tech. Support Mail: 1900 Prairie City Rd. MS FM1-102
- Intel Corporation Folsom, CA 95630
- ===========================================================================
-