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 (June 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 26 Jun 2007 15:15:22 +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: Macro variable for Data set name is being "parsed",
              creating multiple data sets
Comments: To: rpa9@cdc.gov
In-Reply-To:  <229B39BA33B8B445B288898FA99CBD8C023115BF@LTA3VS002.ees.hhs.gov>
Content-Type: text/plain; format=flowed

Rodeny ,

Okay just figured it out I think. Looks like the %QScan is adding unprintable characters to yoru DSN macro value at the beggining and end of the value. When referneced in the Data Step as the Data Step name it cant resolve these so it parse the value into three parts.

If you insist on using %QScan or any quoted value as teh data step name try this:

Data %Unquote( &DSN._2006 ) ;

However, I will caution you that if you have characters that need to be quoted you will need to change those first to something that SAS will like in the context of a Data Step Name.

Toby Dunn

If anything simply cannot go wrong, it will anyway. Murphys Law #2.

The buddy system is essential to your survival; it gives the enemy somebody else to shoot at. Murphys Law #

Tell a man there are 300 billion stars in the universe and he'll believe you. Tell him a bench has wet paint on it and he'll have to touch to be sure. Murphys Law #9

From: "Presley, Rodney (CDC/CCHP/NCBDDD)" <rpa9@cdc.gov> To: "toby dunn" <tobydunn@hotmail.com>,SAS-L@LISTSERV.UGA.EDU Subject: RE: Macro variable for Data set name is being "parsed", creating multiple data sets Date: Tue, 26 Jun 2007 10:18:24 -0400

Toby,

My apologies. I thought the log would be sufficient. This is the code.

%macro regions(regions=); %put regions=&regions.....; %do i=1 %to 13; %let reg=%qscan(&regions,&i,%str( )); %put Value of region is &reg; %let dsn=region&reg.2006; %put Value of dsn is &dsn ; data work.&dsn; set zip_htc_r(where=(region="&reg")); run; %end; %mend regions ; %regions(regions=&u_region);

I am using %qscan instead of %scan because some of the values of &regions will have underscores and who knows what else. If this is not needed I can go back to %scan.

I am using %str( ) because I want the only delimiter to be a single space.

And yes you guessed it the larger, but not that big, data set is being broken up at the request of our internal client.

Thanks,

Rodney

Rodney J. Presley, PhD Division of Hereditary Blood Disorders Work Phone: 404-718-8630 Main Number: 404-718-8600 Fax: 404-718-8650 Email: RPresley@cdc.gov

-----Original Message----- From: toby dunn [mailto:tobydunn@hotmail.com] Sent: Tuesday, June 26, 2007 10:09 AM To: Presley, Rodney (CDC/CCHP/NCBDDD); SAS-L@LISTSERV.UGA.EDU Subject: RE: Macro variable for Data set name is being "parsed", creating multiple data sets

Rodney ,

In all actuallity I think we would need to see yoru code rather than a log excerpt as the log only tells part of the story. I did notice that you were using macro quoting although I have no clue as to why. I would eliminate this first. Finally I wouldnt break up a data set unless the boss or client explicitly asked for it.

Toby Dunn

If anything simply cannot go wrong, it will anyway. Murphys Law #2.

The buddy system is essential to your survival; it gives the enemy somebody else to shoot at. Murphys Law #

Tell a man there are 300 billion stars in the universe and he'll believe

you. Tell him a bench has wet paint on it and he'll have to touch to be sure. Murphys Law #9

From: "Presley, Rodney (CDC/CCHP/NCBDDD)" <rpa9@CDC.GOV> Reply-To: "Presley, Rodney (CDC/CCHP/NCBDDD)" <rpa9@CDC.GOV> To: SAS-L@LISTSERV.UGA.EDU Subject: Macro variable for Data set name is being "parsed",

creating multiple data sets Date: Tue, 26 Jun 2007 09:39:02 -0400

A macro is being used to produce multiple data sets that are subsets of a larger data set. Each iteration of the macro produces a data set -- at least that is what is desired. But as you can see, from one iteration excerpted from the log, three data sets are being produced. It is as if the mavro variable DSN is being parsed. What is happening?

SYMBOLGEN: Macro variable DSN resolves to regionIV_S_2006

But data sets "REGION", "IV_S", and "_2006" are beibg created.

Rodney

Log excerpt:

MLOGIC(REGIONS): %DO loop index variable I is now 5; loop will iterate again. MLOGIC(REGIONS): %LET (variable name is REG) SYMBOLGEN: Macro variable REGIONS resolves to I II III IV_N IV_S IX VI VII VIII V_E V_W X SYMBOLGEN: Macro variable I resolves to 5 MLOGIC(REGIONS): %PUT Value of region is &reg SYMBOLGEN: Macro variable REG resolves to IV_S SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. Value of region is IV_S MLOGIC(REGIONS): %LET (variable name is DSN) SYMBOLGEN: Macro variable REG resolves to IV_S SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. MLOGIC(REGIONS): %PUT Value of dsn is &dsn SYMBOLGEN: Macro variable DSN resolves to regionIV_S_2006 SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. Value of dsn is regionIV_S_2006 SYMBOLGEN: Macro variable DSN resolves to regionIV_S_2006 SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. MPRINT(REGIONS): data work.regionIV_S_2006; SYMBOLGEN: Macro variable REG resolves to IV_S SYMBOLGEN: Some characters in the above value which were subject to macro quoting have been unquoted for printing. MPRINT(REGIONS): set zip_htc_r(where=(region="IV_S")); MPRINT(REGIONS): run;

NOTE: There were 89 observations read from the data set WORK.ZIP_HTC_R. WHERE region='IV_S'; NOTE: The data set WORK.REGION has 89 observations and 144 variables. NOTE: The data set WORK.IV_S has 89 observations and 144 variables. NOTE: The data set WORK._2006 has 89 observations and 144 variables. NOTE: DATA statement used (Total process time): real time 0.03 seconds cpu time 0.03 seconds

Rodney J. Presley, PhD Division of Hereditary Blood Disorders National Center on Birth Defects and Developmental Disabilities Centers for Disease Control and Prevention 1600 Clifton Road, MS E 64 Atlanta, GA 30333 Work Phone: 404-718-8630 Main Number: 404-718-8600 Fax: 404-718-8650 Email: RPresley@cdc.gov

_________________________________________________________________ Make every IM count. Download Messenger and join the i'm Initiative now.

It's free. http://im.live.com/messenger/im/home/?source=TAGHM_June07

_________________________________________________________________ Make every IM count. Download Messenger and join the iím Initiative now. Itís free. http://im.live.com/messenger/im/home/?source=TAGHM_June07


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