04-27-2017 02:56 PM
I would like to name the title of a html output using a sas macro that will run with a do loop for multiple iterations in SAS 9.4:
The current code is %macro test (st,xst1);
followed by, e.g., %test ('CA',CA15);
The dataset where the table (in HTML format) will be output has the following where statement:
where statefip IN (&st);
There is a year variable where there are observations with '15 values. Is there a way that I can draw this information out as a macro variable to apply for all files?
I am confused about the logic behind "xst1".
Thank you in advance for any comments and suggestions!
04-27-2017 03:17 PM
It sounds like you need more experience with macro language, to figure out what it is doing.
Look through your macro, with these guidelines:
Whatever SAS program results from those text substitutions, that is the program that is running.
Obviously, there is more to macro language than this. But that's a good starting point.
04-27-2017 03:28 PM
Thank you! Follow-up question: Does single quotes or double quotes matter for 'CA'?
I have been going through past articles from Art Carpenter and think that his macro reference would help for this and other tasks. Are there any other references that I can read up on?
04-27-2017 03:44 PM
Single vs. double quotes in 'CA' probably make no difference. It depends on what the SAS statement looks like after substituting those 4 characters for &ST.
As a general rule, single vs. double quotes make a big difference when referring to a macro variable. Single quotes suppress all macro activity. So:
"&xst1" will resolve and become "CA15"
'&xst1' will not resolve and will remain '&xst1'
There are dozens of papers out there on macro language. Art's book is good, but you can get started today with a little searching without having to wait for a book to arrive.
04-28-2017 08:52 AM