Date: Thu, 1 Oct 2009 09:58:40 -0500
Reply-To: "Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: How to add a column with order(1,2,3...) like obs in print?
In-Reply-To: <169484c2-488f-427d-9920-0a30ea56e6d9@t32g2000yqj.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
To me the "best" method is to choose a tool that knows SAS, knows what
an SAS enumerated variable list is and how it should most logically be
ordered. That tool is PROC CONTENTS.
data q;
attrib q12P3R1 Q12P3R10 Q12P3r2 Q12P3R3 length=8;
stop;
run;
proc contents order=ignorecase noprint out=names(keep=name);
run;
proc print;
run;
proc sql noprint;
select name into :orderedList separated by ' ' from names;
quit;
run;
%put NOTE: ORDEREDLIST=&orderedList;
On 10/1/09, demin <qdmiris@gmail.com> wrote:
> Because I did something and made the order of my table has been
> changed, so I would like to add a order column to keep the old order.
> How to add such column with order 1,2,3...?
>
> Actually the column is character type, like :
> Q12P3R1
> Q12P3R10 ? shis should be placed on the last one, but
> Q12P3R2
> Q12P3R3
> ...
> ?Q12P3R10 should be placed on the last one, but by "proc sql select
> *... order by ..." till cannot get the order I want. how to solve
> this? thanks.
>
|