There are several different solutions; this is one of them. The variables
names are automatically determined and alphabetically put into a macro
variable, which is used in a RETAIN statement.
data cba; c=1; b=2; a=3; run;
proc print data=cba; run;
proc contents data=cba out=contents (KEEP=Name) noprint; run;
data _null_; set contents; call execute ('%LET VarList=&Varlist ' || Name);
data abc; retain &VarList; set cba; run;
proc print data=abc; run;
Regards - Jim.
Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070
senior statist./data man. P.O. Box 1 fax. +31 412 407 080
J.Groeneveld@ITGroups.com 5350 AA BERGHEM, NL www.imrotramarko.com
IF Annoying=T THEN Salutation=''; ELSE IF Sex='M' THEN Salutation='Hi'; ELSE
IF Sex='F' THEN Salutation='Dear'; ELSE /* unknown, more, all */
Notice of confidentiality: this e-mail may contain confidential information
intended for the addressed recipient only.
If you have received this e-mail in error please delete this e-mail and
please notify the sender so that proper delivery can be arranged.
> -----Original Message-----
> From: Kurian, Jeomoan T (CAP, ACOE)
> Sent: 18 February 2003 10:27
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: how to rearrange the columns in SAS record set on an
> alphabetica l order?
> I deal with a record set which has 330 plus columns and not
> listed in any
> particular order. It would be easier for me to do a walk
> through id the
> columns are arranged in alphabetical order. I tried 'retain'
> before set
> <recordset> and its ok for smaller datasets. When every time I have
> different variables this becomes very difficult..
> Please let me know any tips ?
> thanks in advance,
> This e-mail, together with any attachments, is
> confidential. It may be read, copied and used only by the intended
> recipient. If you have received it in error, please notify the sender
> immediately by e-mail or telephone. Please then delete it from your
> computer without making any copies or disclosing it to any
> other person.Any
> unauthorised copying, disclosure or distribution of the
> material in this