LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (January 2009, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 21 Jan 2009 09:08:42 -0500
Reply-To:   Akshaya Nathilvar <akshaya.nathilvar@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Akshaya Nathilvar <akshaya.nathilvar@GMAIL.COM>
Subject:   Re: reorder item in proc sql
Comments:   To: nina <sas@mailinator.com>
In-Reply-To:   <gl74m0$a39$1@news.motzarella.org>
Content-Type:   text/plain; charset=ISO-8859-1

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; >


Back to: Top of message | Previous page | Main SAS-L page