Your SAS programs, embedded in web apps and elsewhere

Pass Blank Value to SAS Dynamic SQL Macro

Accepted Solution Solved
Reply
Super Contributor
Posts: 497
Accepted Solution

Pass Blank Value to SAS Dynamic SQL Macro

  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 “”


Accepted Solutions
Solution
‎03-03-2015 04:10 PM
Super User
Posts: 5,516

Re: Pass Blank Value to SAS Dynamic SQL Macro

Posted in reply to DavidPhillips2

Passing a null value should be easy:

%MyMacro ()

View solution in original post


All Replies
Super Contributor
Posts: 497

Re: Pass Blank Value to SAS Dynamic SQL Macro

Posted in reply to DavidPhillips2

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;



Solution
‎03-03-2015 04:10 PM
Super User
Posts: 5,516

Re: Pass Blank Value to SAS Dynamic SQL Macro

Posted in reply to DavidPhillips2

Passing a null value should be easy:

%MyMacro ()

Super Contributor
Posts: 497

Re: Pass Blank Value to SAS Dynamic SQL Macro

Posted in reply to Astounding

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.

Super User
Posts: 5,516

Re: Pass Blank Value to SAS Dynamic SQL Macro

Posted in reply to DavidPhillips2

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.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 1038 views
  • 0 likes
  • 2 in conversation