|
How would you define the ITEMORDER, if more than one NUM1 from B matches
NUM1 from A? However, with your sample data, the following code resorts the
item order.
Proc sort data=a;
by num1;
Run;
Proc sort data=b;
by num1;
Run;
Data c;
merge a(in=x) b(in=y);
by num1;
if x and y then itemorder=1;
else itemorder=itemorder;
if x;
Run;
Akshaya!
On Wed, Jan 21, 2009 at 7:33 AM, nina <sas@mailinator.com> wrote:
> need a little help on how to do this in proc sql.
> the goal is to see if num1 is found in "data b" and if so, that resequences
> itemorder
>
> data a;infile cards dsd;
> input num1 typecode $ itemorder itemdate $6.;
> cards;
> 40010001,M,3,110108
> 20010001,G,1,040407
> 10010001,T,5,040407
> 60010001,B,2,050107
> ;;;;
> proc sql;create table sorted as select * from a order by itemorder;quit;
> data _null_;set ;put(_all_)(=);run;
> data b;infile cards;
> input num1;
> cards;
> 90010001
> 10010001
> ;;;;
> run;
> * desired output
> num1=10010001 typecode=T itemorder=1 itemdate=040407
> num1=20010001 typecode=G itemorder=1 itemdate=040407
> num1=60010001 typecode=B itemorder=2 itemdate=050107
> num1=40010001 typecode=M itemorder=3 itemdate=110108;
>
|