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 2003, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 24 Jan 2003 19:29:29 GMT
Reply-To:   JP <crughy@BIGFOOT.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   JP <crughy@BIGFOOT.COM>
Organization:   Pas très organisé
Subject:   Re: PROC SQL Question

quandagarland@yahoo.com (Garland) wrote in news:2fb667c8.0301240854.218ec442@posting.google.com:

> Hi, > > I have the following program. Can anybody give me the PROC SQL query > for the following datastep. I am learing proc sql just started to > convert the previously written programs to proc sql as an exercise. > > Thanks in advance, > Garland > > Data ds1; > Input subjid lbtst$ lowhigh $; > Datalines; > 1001 ALBUMIN NH > 1001 BUN NL > 1002 CALCIUM NH > 1002 BUN NL > 1002 LDH NH > ; > > Data ds2; > Input subjid studydy lbtst$ ; > Datalines; > 1001 0 ALBUMIN > 1001 1 ALBUMIN > 1001 7 ALBUMIN > 1001 14 ALBUMIN > 1001 0 BUN > 1001 1 BUN > 1001 1 URIC_ACID > 1001 2 GLUCOSE > 1002 1 CALCIUM > 1002 1 BUN > 1002 0 LDH > 1003 2 SODIUM > 1003 2 LDH > ; > > run; > > proc sort data=ds1; > by subjid lbtst; > run; > > proc sort data=ds2; > by subjid lbtst; > run; > > data dm; > merge ds1(in=aa) ds2; > by subjid lbtst; > if aa; > run; >

Here is an example:

PROC SQL; CREATE TABLE dm2 AS SELECT id.*, sce.* FROM ds1 AS id, ds2 AS sce WHERE id.subjid= sce.subjid AND id.lbtst= sce.lbtst ; QUIT;

PROC COMPARE DATA=dm COMP=dm2;RUN;

Get a very nice SQL introduction, from Chris Yindra, from C.Y. Associates An introduction to the SQL procedure (check google)

Simple and easy learning.

JP


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