LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (February 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sun, 20 Feb 2005 12:21:24 +0000
Reply-To:     datametric@CLUB-INTERNET.FR
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         SUBSCRIBE SAS-L Stephane <datametric@CLUB-INTERNET.FR>
Subject:      Re: Newbie Question on how to subset a data set by unique values
              of a
Comments: To: enstrophy_2000@YAHOO.COM
Content-Type: text/plain; charset=ISO-8859-1

Hi Yu,

see the output statements :

*Way 1 : ; data set1 set2 set3; * define the output datasets ; set price; *read the main table;

*redirecting the data; if var1='aa' then output set1; else if var1='bb' then output set2; else output set3; run;

*Way 2 : faster than others with huge table; data set1 set2 set3; set price; select (var1); when ('aa') output set1; when ('bb') output set2; otherwise output set3; end; run;

I don't know what you mean with your 'label' but you can add an label with a data statement but to name a dataset, you have to use "data XXX ;" all the time.

Have a good sunday.

Stéphane.

----Message d'origine---- >Date: Sat, 19 Feb 2005 16:00:18 -0800 >De: enstrophy <enstrophy_2000@YAHOO.COM> >Sujet: Newbie Question on how to subset a data set by unique values of a >A: SAS-L@LISTSERV.UGA.EDU > >Hi, > I'm new to SAS and am confronted by a task of subsetting >a data set accroding to unique values of a given variable. >For example, for the following data set: > >Label Price >aa 1.2 >bb 2.4 >aa 3.0 >cc 2.4 >cc 1.5 > >the objective is to create several data sets, each with >a unique Label, i.e., > >data set 1: >Label Price >aa 1.2 >aa 3.0 > >data set 2: >Label Price >bb 2.4 > > >data set 3: >Label Price >cc 2.4 >cc 1.5 > >I wonder what would would be the most straightforward >way of doing this? I was thinking about using >proc freq to get the unique values of Label, then >looping through each value, and subsetting the original >data set according to it. However, I have not been >able to figure out how to perform a loop for anything >other than an array. Any help will be greatly appreciated. > >-Yu > >


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