comp.soft-sys.sas - The SAS statistics package.
Hi All, I want to create a macro varible holding two or more values from two or more macro calls. OPTION SYMBOLGEN MPRINT MLOGIC; %LET IDVAL; %LET PERSON; data a; input ID; datalines; 1 2 ; %MACRO CALLS(PER); PROC SQL; *create table x1 as; SELECT ID, "&&PER" AS MAN INTO :IDVAL , :PERSON SEPARATED BY ',' FROM A; QUIT; %MEND CALLS; %CALLS(John); %CALLS(Smith); %PUT &IDVAL; %PUT &PERSON; Here at the end of the second call "Smith", I am seeing the value of only Smith, but not "John, Smith". Help please. Thanks
Hi Toby, I agree 99.99% with you. And as far as empty or missing macro values is concerned, I think it merely is a matter of naming such values. Because missing dataset values are treated as missing automatically by statistical PROCs, they are special, regarded missing. Missing macro values never are treated differently, special in any way. That is why I prefer not to call them missing, to avoid confusion. But you and I know what we mean, what those values are. And if you or anyone else prefer to call them missing, I don't mind. So, after all, I think we only disagree for .01%, just about a name for the concept. Well Toby, I liked this discussion ;-) Regards - Jim. . . . . . . . . . . . . . . . . Jim Groeneveld, MSc. Biostatistician Science Team Vitatron B.V. Meander 1051 6825 MJ Arnhem Tel: +31/0 26 376 7365 Fax: +31/0 26 376 7305 XXXX@XXXXX.COM www.vitatron.com Showing statistically significant differences between football teams, generally all sporters, requires larger samples than usually applied. [common disclaimer] -----Original Message----- From: Dunn, Toby [mailto: XXXX@XXXXX.COM ] Sent: Wednesday, June 30, 2004 15:38 To: Groeneveld, Jim Cc: SAS-L (E-mail) Subject: RE: Macro Variable Problem Jim, I still disagree with you and we may very well have to leave it at that. I see SAS code and the Macro language as being separate languages but two that can work together. Hence the reason you, me and others say "macro language". The Language part is what I believe is important. By denoting it as being a language separate from SAS open code; we automatically segregate it off from the rest of the SAS language. Therefore one can't say that a macro variable is comparable to a SAS data set variable. It has to be thought of as and treated differently than a SAS data set variable (the reason I believe that there is a lot of confusion with beginners writing macro code). Thus, in that light I say that a macro variable can have a missing value. Because of the fact that a macro variable holds text values a " " is missing in macro land, which is different that a missing text value in a variable that is in a SAS dataset. Hope this is clearer than my last email. Toby Dunn -----Original Message----- From: Groeneveld, Jim [mailto: XXXX@XXXXX.COM ] Sent: Wednesday, June 30, 2004 2:59 AM To: Dunn, Toby Cc: SAS-L (E-mail) Subject: Re: Macro Variable Problem Hi Toby, Yes, of course a macro variable may be empty, but that does not mean anything special in macro language, like missing values from datasets are automatically treated specially (missing) in various statistical PROCs. So, I would not call it missing, and certainly not in the sense like a SAS dataset variable may be missing. It wrongly would suggest a relation with SAS variables and a concept which does not exist. A macro variable only contains text, which may be the absence of contents, with a %length of zero. So I do stick to my statement that the concept of missing values does not exist in macro language. I would only call the absence of a value an empty value. But an empty value is being processed just like any non-empty value. It often may be the initial value of a list being built. Regards - Jim. . . . . . . . . . . . . . . . . Jim Groeneveld, MSc. Biostatistician Science Team Vitatron B.V. Meander 1051 6825 MJ Arnhem Tel: +31/0 26 376 7365 Fax: +31/0 26 376 7305 XXXX@XXXXX.COM www.vitatron.com Showing statistically significant differences between football teams, generally all sporters, requires larger samples than usually applied. [common disclaimer] -----Original Message----- From: Dunn, Toby [mailto: XXXX@XXXXX.COM ] Sent: Tuesday, June 29, 2004 18:31 To: Groeneveld, Jim Subject: RE: Re: Macro Variable Problem Jim, I was wondering about something you said, "The concept of missing values does not exist in macro language." I would have to say it does. Take the simple case of "%let macvar = ;" the blank here is just missing character data, nothing more nothing less. So there is a concept of missing data (whether it is intentionally left as blank or because of a program design flaw). Toby Dunn [.........]
Hi, I have defined a variable called k in a do loop and then try to create a macro out of it, but unable to do it. %let proc_dt1 = 200507; %let proc_dt2 = 200508; %let proc_dt3 = 200509; %let proc_dt4 = 200510; %put &proc_dt1; %put &proc_dt2; %put &proc_dt3; %put &proc_dt4; %let proc_dt = proc_dt; %put &proc_dt; data _null_; %put &proc_dt10; do k = 1 to 4; %let k = k; %put &&proc_dt&k; end; run; Can I assign a variable to create a macro variable? Thank you, Papu.
Hello all, I would like to get a variable name "trx" changed to something like "mic_200803" by running the following code. But it failed. Can you help? ------- code ------ %let endmo=1mar2008; %macro test(dsn=); data &dsn; sasdate=intnx('month',"endmo"d,0)); call symput('yyyymm',put(sasdate,yymmn6.)); set &dsn (rename=trx=&dsn._trx_&yyyymm); run; %mend; %test(dsn=mic); ----- log --------- MPRINT(RUNMARKET): ; SYMBOLGEN: Macro variable DSN resolves to mic MPRINT(RENAMEIT): data mic; SYMBOLGEN: Macro variable ENDMO resolves to 01mar2008 MPRINT(RENAMEIT): sasdate=intnx('month',"01mar2008"d,0); MPRINT(RENAMEIT): call symput('yyyymm',put(sasdate,yymmn6.)); SYMBOLGEN: Macro variable DSN resolves to mic WARNING: Apparent symbolic reference YYYYMM not resolved. Susie Chung Li