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 (March 2008, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 11 Mar 2008 20:44:05 -0400
Reply-To:   "Howard Schreier <hs AT dc-sug DOT org>" <schreier.junk.mail@GMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Howard Schreier <hs AT dc-sug DOT org>" <schreier.junk.mail@GMAIL.COM>
Subject:   Re: Proc SQL to create multiple sub-tables?

On Tue, 11 Mar 2008 15:59:29 -0700, Peter <crawfordsoftware@GMAIL.COM> wrote:

>On Mar 11, 10:01 pm, Ruve <band...@gmail.com> wrote: >> In the following data step example, dataset a is read only once to >> create the three sub-datasets (a1, a2, a3). How to implement this in >> Proc SQL without efficiency sacrifice? Thanks! >> >> data a; >> input x; >> cards; >> 1 >> 2 >> 3 >> 5 >> 4 >> 9 >> 2 >> 1 >> 6 >> ; >> run; >> >> data a1 a2 a3; >> set a; >> if x=1 then output a1; >> else if x=2 then output a2; >> else output a3; >> run; > >Why not use the datastep? Why require sql ?

Why? Suppose that the source is not the existing data set A, but rather some process which is most advantageously implemented in SQL. What Ruve wants to do is not possible, but the next best thing is to wrap a CREATE VIEW AS around the SQL query, and include X as one of the columns (probably populating it by means of a CASE expression). Then run the splitter DATA step against the view.


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