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 (February 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 14 Feb 2006 05:30:58 -0500
Reply-To:   Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Gerhard Hellriegel <ghellrieg@T-ONLINE.DE>
Subject:   Re: Macro LET statement equivalent of Call Symput;

That should work better:

%global ym; options mprint mlogic symbolgen; %macro t(sy=,ey=,sm=,em=); /*%let month=&mon;*/ %do i=&sy %to &ey; %do j=&sm %to &em; data _null_; call symput('ym',substr(put(intnx('year','01jan01'd,&i),ddmmyy10.),7,4)!! trim(left(trim("0")||left(trim(&j))))); run; %let lib=libname admin&ym "d:\vfs\store\&ym"; %put &lib; %end; %end;

%mend t;

the data _null_ - step must be finished before u use the macro variable. If you have the %let in the data-step, it is executed (resolved) BEFORE the data-step runs.

On Tue, 14 Feb 2006 01:45:29 -0800, easwara@GMAIL.COM wrote:

>Hi , > >I have a problem in the following code. I need to create dynamic >libname statements like the following: > >libname admin200201 'd:\vfs\store\200201'; /* These are existing >folders */ >libname admin200202 'd:\vfs\store\200202'; >libname admin200203 'd:\vfs\store\200203'; >.... >... >.. >libname admin200201 'd:\vfs\store\200312'; > >When I execute the code, the macro variable YM , is not resolved in the >first run, as I've used call symput, which effectively creates the YM >variable after the datastep execution. How do I convert the CALL SYMPUT >STEP into a legal %let statement , so that I create the variable before >I create my Libname statment. Am I right in finding this issue or is >there any other error in the macro logic? :( > >Thanks >Moorthy > >/* Code */ > >%global ym; >options mprint mlogic symbolgen; >%macro t(sy=,ey=,sm=,em=); >/*%let month=&mon;*/ >%do i=&sy %to &ey; >%do j=&sm %to &em; >data _null_; >call >symput('ym',substr(put(intnx('year','01jan01'd,&i),ddmmyy10.),7,4)!! > trim(left(trim("0")||left(trim(&j))))); >%let lib=libname admin&ym "d:\vfs\store\&ym"; >%put &lib; >%end; >%end; >run; > >%mend t; > >%t(sy=1,ey=2, sm=1, em=12);


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