|
Hi Dianne
Use this example:
/************************/
data x1;
input var1 var2 var3;
datalines;
1 2 4
1 4 4
4 3 6
7 5 9
;
run;
title;
title1 " data x1 ";
proc print data=x1;
run;
/* in data x1 the order of variables is:
var1 var2 var3 */
/* suppose you wante them in oder:
var1 var3 var2 */
proc sql;
create table x2 as
select var1 ,var3, var2
from x1;
quit;
title2 " data x2 ";
proc print data=x2;
run;
/****************************/
Barrere.
-----Original Message-----
From: Robert Abelson [mailto:rabelson@KAI-RESEARCH.COM]
Sent: March 15, 2002 4:28 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: How change variable's order in a sas dataset?
As I recall, at one time PROC SORT wouldn't work if any of the BY variables
was past a certain position in the dataset. That's when I first learned
about using RETAIN to reorder the variables in the dataset (around 1985
IIRC). Obviously, SAS has improved PROC SORT so that this is no longer the
case.
Bob Abelson
KAI
6001 Montrose Rd.
Suite 920
Rockville, MD 20852
T: 301-770-2730
F: 301-770-4183
rabelson@kai-research.com
> -----Original Message-----
> From: Dianne Rhodes [SMTP:RHODESD1@WESTAT.COM]
> Sent: Friday, March 15, 2002 4:17 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: How change variable's order in a sas dataset?
>
> >IanWhitlock@westat.com wrote:
>
> > >Thus it is very likely that use of RETAIN to reorder
> >variables goes back to
> >the beginning of SAS.
> >
> Yes, that is what I was taught in 1978.
> However some of the other features of RETAIN have changed a good bit.
> The statement that I learned was that RETAIN is not executable and can
> appear anywhere in the datastep. This is true, with the exception of
> RETAIN
> _ALL_
> Then the position matters.
>
> I recall that I frequently used this feature as a Research Assistant at
> Urban Institute (1980-1982) when I
> wanted to sort a large file on the MainFrame, to move the variable I was
> sorting on to the beginning of the file
> to make the sort run faster. That would have been at Dial Tyme under
> SuperWylbur.
>
>
> Dianne Louise Rhodes
> Sr. Systems Analyst
> Westat
|