Date: Mon, 3 Oct 2005 16:18:07 -0000
Reply-To: sa polo <solouga4@rediffmail.com>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: sa polo <solouga4@REDIFFMAIL.COM>
Subject: Re: WARNING: Apparent symbolic reference _K not resolved !!??
Content-Type: text/plain; charset=iso-8859-1
Thanks Chang,
I have used your edits to change my program but while
i create a file using a FILE statement in a DATA STEP
i get the WARNING: Apparent symbolic reference _K not resolved !!??
i would like to get rid of this message.
Also i need to invoke the macro through a CALL EXECUTE as i am
reading the Id from within a DATA STEP.
Any help is much appreciated as usual.
proc format;
value fname
0801 = "S & K"
;
run;
%macro fname(id);
%*-- returns filename based on the input number --*;
%local number name;
%let number = %sysfunc(putn(&id., z4.));
%let name = %qsysfunc(putn(&id., fname.));
%let name = %qsysfunc(strip(&name.));
%let name = %qsysfunc(translate(&name., "_", " "));
/* %*;&number.-&name.*/
%put test= "&number.-&name.";
DATA _NULL_;
FILE "c:\&number.-%SUPERQ(name).csv";
RUN;
%mend fname;
DATA _NULL_;
CALL EXECUTE('%fname('||801||')');
RUN;
Sa Polo
On Mon, 03 Oct 2005 Chang Chung wrote :
>On Mon, 3 Oct 2005 14:21:59 -0000, sa polo <solouga4@REDIFFMAIL.COM> wrote:
>
> > Hi All,
>
>I have written a program which essentially takes certain
>parameters from a macro call and based on a format
>creates a file and writes data to it, which in
>this case is the file name itself.
>
>All this works well but for the fact that i get
>warning messages i.e
>WARNING: Apparent symbolic reference _K not resolved.
>I have tried using %SUPERQ but without success.
>I need to use CALL EXECUTE() since in the complete
>version of the program i read these values in a data step.
>
>Any help is much appreciated as usual.
>
>Sa Polo
>
>PROC FORMAT LIBRARY=WORK;
>VALUE FFmt
>0801 = "S & K";
>run;
>
>%MACRO ToCsv(Start);
>DATA _NULL_;
>FIRM=PUT(&Start,FFmt.);
>FirmUnderscore=TRANSLATE(STRIP(Firm),'_',' ');
>SpecFileNameAppend=CATX("-",PUT(&Start,z4.),FirmUnderscore);
>CALL SYMPUTX("SpecFile",SpecFileNameAppend);
>RUN;
>
>%PUT SpecFile=%SUPERQ(SpecFile);
>
>DATA _NULL_;
>FILE "c:\%SUPERQ(SpecFile).csv";
>PUT "%SUPERQ(SpecFile)";
>run;
>%MEND;
>
>
>%MACRO Fname() ;
>DATA _NULL_;
>CALL EXECUTE('%ToCsv('||'801'||')');run;
>%MEND ;
>%Fname() ;
>
>
>Hi, Sa,
>
>I have to admit that you have very interesting style of macro coding. You
>are obviously not alone. I see many pieces of macro code unnecessarily (in
>my humble opinion) mixed with data _null_ step, call execute(), and call
>symput(). There must be some good reasons that I don’t know about. There may
>be benefits of this particular programming style. Please share the good
>reason(s) with me, if there are.
>
>In any case, it seems that you are writing a macro to generate a file name
>given an id number. The generated filename should be the id number formatted
>with z4. and the matching filename (given by a format). The formatted id
>number and the filename should be concatenated together with a dash (‘-‘) in
>between. If this is the task, then I would suggest a simple function-style
>macro as shown below. HTH.
>
>Cheers,
>Chang
>
>proc format;
> value fname
> 0801 = "S & K"
> ;
>run;
>
>%macro fname(id);
>%*-- returns filename based on the input number --*;
> %local number name;
> %let number = %sysfunc(putn(&id., z4.));
> %let name = %qsysfunc(putn(&id., fname.));
> %let name = %qsysfunc(strip(&name.));
> %let name = %qsysfunc(translate(&name., "_", " "));
> %*;&number.-&name.
>%mend fname;
>
>%put fname=%fname(801);
>/* on log
>fname=0801-S_&_K
>*/
|