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 2007, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 12 Jan 2007 16:40:14 +0000
Reply-To:   toby dunn <tobydunn@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   toby dunn <tobydunn@HOTMAIL.COM>
Subject:   Re: help for proc sql
Comments:   To: program.sas@GMAIL.COM
In-Reply-To:   <200701121628.l0CBkepJ003120@malibu.cc.uga.edu>
Content-Type:   text/plain; format=flowed

Jane ,

Most of programming is knowing the right tool for the job, even if that means it takes learning something knew. SQL isnt the ideal proc for this task consider the following code:

data have; input a b c; datalines; 1 2 11 1 2 22 1 2 33 2 3 11 2 3 22 3 4 11 3 4 33 ; run;

Proc Transpose Data = Have Out = Need Prefix = c ; By A ; Var B ; ID C ; Run ;

Data Need ( Drop = I _Name_ ) ; Set Need ; Array C ( * ) C: ;

Do I = 1 To Dim ( C ) ; If Not Missing( C( I ) ) Then C( I ) = 1 ; Else C( I ) = 0 ; End ; Run ;

Proc Print Data = Need ; Run ;

Toby Dunn

To sensible men, every day is a day of reckoning. ~John W. Gardner

The important thing is this: To be able at any moment to sacrifice that which we are for what we could become. ~Charles DuBois

Don't get your knickers in a knot. Nothing is solved and it just makes you walk funny. ~Kathryn Carpenter

From: Jane <program.sas@GMAIL.COM> Reply-To: Jane <program.sas@GMAIL.COM> To: SAS-L@LISTSERV.UGA.EDU Subject: help for proc sql Date: Fri, 12 Jan 2007 11:28:59 -0500

I have a dataset like this

data have; input a b c; datalines; 1 2 11 1 2 22 1 2 33 2 3 11 2 3 22 3 4 11 3 4 33 ;; run;

I want to output like this: a b 11 22 33 --------------------- 1 2 1 1 1 2 3 1 1 0 3 4 1 0 1

Here is my proc sql code;

proc sql; select distinct a, b, c=11 as c11, c=22 as c22, c=33 as c33 from have; quit;

but the output is: a b c11 c22 c33

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ 1 2 0 0 1 1 2 0 1 0 1 2 1 0 0 2 3 0 1 0 2 3 1 0 0 3 4 0 0 1 3 4 1 0 0 Thanks Jane

_________________________________________________________________ Type your favorite song. Get a customized station. Try MSN Radio powered by Pandora. http://radio.msn.com/?icid=T002MSN03A07001


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