BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
grodman
Obsidian | Level 7

Hello -

I have a report that dynamically runs a proc-report to produce ODS output.  The columns of the report, and corresponding define statements, are dynamically populated depending on the columns that the user chooses.  However, some of these columns need to have title that start with a "%".  Using the code below, the program runs and builds the columns of the report, but when it tries to give the title of "%oftotal" to the column, the report breaks because it thinks it's looking for a macro called "oftotal".  Is there a way to suppress this warning, or make it so that the variable gets resolved without trying to invoke the "oftotal" macro?

Please help!

data work.data;

  infile datalines delimiter=',';

  format value 5. name $25.;

  input value name;

  datalines;

5,%oftotal(2013)

;

run;

data _null_;

  set work.data;

  call symputx("sortvariable", name);

run;

proc report data=work.data;

  columns value;

  define value / "&name";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19
data work.data;
   infile datalines dsd;
  
informat value 5. name $25.;
  
input value name;
   call symputx("name", name);
   datalines;
5,%oftotal(2013)
;;;;
   run;

proc report data=work.data;
   columns value;
   define value / "%superQ(name)";
  
run;

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

I'm confused.  You create a macro variable called &sortvariable, but then try to access a macro variable called &name.

Am I missing something here?

grodman
Obsidian | Level 7

I got it backwards... I am trying to access the "sortname" macro variable... change is shown below.

data work.data;

  infile datalines delimiter=',';

  format value 5. name $25.;

  input value name;

  datalines;

5,%oftotal(2013)

;

run;

data _null_;

  set work.data;

  call symputx("sortvariable", name);

run;

proc report data=work.data;

  columns value;

  define value / "&sortvariable";

run;

data_null__
Jade | Level 19
data work.data;
   infile datalines dsd;
  
informat value 5. name $25.;
  
input value name;
   call symputx("name", name);
   datalines;
5,%oftotal(2013)
;;;;
   run;

proc report data=work.data;
   columns value;
   define value / "%superQ(name)";
  
run;
grodman
Obsidian | Level 7

This worked!  Thank you very much!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1628 views
  • 0 likes
  • 3 in conversation