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 (July 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 5 Jul 2006 04:48:17 -0400
Reply-To:     Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <jim2stat@YAHOO.CO.UK>
Subject:      Re: Create dataset names from variable values
Comments: To: Donal KElly <donal.kelly@CSO.IE>

Sorry Donal,

The example SQL code, which I provided is not good. The intention is to generate a list of unique values as a macro variable. You could do that by (*untested*):

PROC FREQ DATA=YourData NOPRINT; TABLES Variable / OUT=Scratch /* or whatever name */ (KEEP=Variable); RUN;

%LET Datasets = ; %* initialize empty list; DATA _NULL_; SET Scratch; CALL EXECUTE ('%LET Datasets = &Datasets ' || LEFT(TRIM(Variable)) || ';' ); RUN; %PUT List of datasets = &Datasets;

But there may be a nice SQL solution as well.

Regards - Jim. -- Jim Groeneveld, Netherlands Statistician, SAS consultant home.hccnet.nl/jim.groeneveld

On Wed, 5 Jul 2006 03:41:15 -0400, Donal Kelly <donal.kelly@CSO.IE> wrote:

>Hi, > >I am trying to split a dataset into 20 individual files and assign a >dataset name based on the value of a certain variable within each dataset >(see sample code below). I can split the file easily enough by looping >through the Region ids, but I can't figure out how to pass the value of >Region for each file to the dataset name. > >I've been trying to pass the value of Region to a macro variable but with >no success. > >ID Region Reg_ID >01 North 1 >02 North 1 >03 South 2 >04 South 2 >05 East 3 >06 East 3 >07 West 4 >08 West 4 > >Outcome > North.sas7bdat, South.sas7bdat etc. . > >I would appreciate any suggestions that are out there. >Donal


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