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!

sas-innovate-2024.png

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.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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