In SAS 9.2
I am converting a series of similar temporary table creation blocks into a macro. I figured out how to write the macro with the
exception of where one table contains one more column than another. I need to be able to pass a blank value into
a macro that won’t throw off my SQL create table statement.
For the column I want I found that I can use
%MyMacro(%str(four_digit_year varchar(4),));
I am not sure what I can use if I want to include a null. Eg.
%MyMacro(null)
It seems that I can’t use “”
The same idea would be useful here. If I could feed in a blank &group into a
template.
proc template;
define statgraph TotalGraph;
dynamic TITLE1 TITLE2;
begingraph;
entrytitle halign=left TITLE1;
entrytitle TITLE2;
layout overlay / xaxisopts =(label = ' ') yaxisopts =(label = ' ' linearopts=(viewmin=0)) walldisplay=(fill);
seriesplot x=FOUR_DIGIT_YEAR y=students_enrolled / &group
name='a' index=index display=all
ROLENAME=(Year=ACADEMIC_PERIOD_DESC Level=&enrRepTy)
TIP=(Year Level Y) tiplabel=(Year='Academic Term' Y='Students Enrolled' Level ='Level') datalabel=students_enrolled;
endlayout;
endgraph;
end;
run;
Passing a null value should be easy:
%MyMacro ()
Worked for me. If you have a method that accepts three parameters and you feed it two SAS feeds only two parameters. Apparently Polymorphism is not included in SAS.
It's not difficult to overcome:
%MyMacro (A,,C)
The first parameter receives a value of A, the second is null, and the third is C. It might be easier to understand if you switch from positional parameters to keyword parameters, though.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.