I have
%inseg10(wu1.custbase2m,work.T8_1a,'N',SA,SAP,'IN1');
%macro inseg10(dsin,dsout,ntb,product1,product2,custclass);
in fact product2=product1||'P';*variable name in a data set ,for eg SA,SAP;
I tried debug in macro inseg10:
%put &product1||'P';
%put &product1||P;
neither output is what I wanted as below
SAP;
How can I use statement in macro using & product1 to constitute product2?
THANKS.
To SAS macro code everything is a string. So if you have a macro variable called PRODUCT1 with the value SA and you want to use it to refer to variables SA and SAP in the actual SAS code that the macro will generate you do not need any concatenation characters. What you need is to use a period to tell SAS not to look for a macro variable named PRODUCT1P.
proc means ;
var &product1 &product1.p ;
run;
Also considering your other thread around this macro (https://communities.sas.com/message/123512#123512) you probabely should give us the full code and also tell us what you have, what you want and what problem you really want to solve.
In my experience a lot of people at a certain stage in their "SAS skills development" tend to overuse macro coding and to forget about simple SAS datastep aproaches. Consider that you should try to write code which you still can easily understand in 6 months time.
patrick,
You are absolutely right. I am on my first time writing macro while with only 4 months experience of SAS.
thanks for your guiding. I will go on.
dawn.
To SAS macro code everything is a string. So if you have a macro variable called PRODUCT1 with the value SA and you want to use it to refer to variables SA and SAP in the actual SAS code that the macro will generate you do not need any concatenation characters. What you need is to use a period to tell SAS not to look for a macro variable named PRODUCT1P.
proc means ;
var &product1 &product1.p ;
run;
Tom,Thanks for your patient explantion. It works. Dawn
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.