BookmarkSubscribeRSS Feed
cnilsen
Quartz | Level 8

Hi All,

I'm sure this is simple to most of you, but is stumping me at the moment. I have a program that builds a detail table. It has start, end date, and company # parms (since this can run for either Brand ID# within our organization.
I then summarize the data and do a proc report. However, I want to change title2 line in the output based off of the Brand ID #.

I am trying this, but my results are not what I expect:

data _null_;
if &brand_code = 10 then call symputx('comp_name','ABC Company');
else call symputx( 'comp_name', 'XYZ Company');
%put &compname = comp_name;
run;

then in the proc report:

 

title1 &startdate ' to ' &enddate;
title2 &compname;

proc report data=work.vendor;
run;

My headings at report output time are :

06/01/2019 to 06/10/19
&compname

----------------------------------------------------------------------
my log shows this:
SYMBOLGEN: Macro variable BRAND_CODE resolves to 10
137 if &brand_code = 10 then call symputx('comp_name','ABC Company');
138 else call symputx( 'comp_name', 'XYZ Company');
139
140 %put &compname = comp_name;
WARNING: Apparent symbolic reference COMPNAME not resolved.
&compname = comp_name

 

 

 

Any help would be appreciated!.

- Chris N.
5 REPLIES 5
cnilsen
Quartz | Level 8

Title1 display correctly with the start & end dates.. as is.

adding quotes to title2 as suggested didn't make a difference and the variable still is unresolved as the log shows:

 

140 %put &compname = comp_name;
WARNING: Apparent symbolic reference COMPNAME not resolved.
&compname = comp_name
141 run;

 

should I be using a different method to set the value of compname for use in the report title?

 

 

- Chris N.
Tom
Super User Tom
Super User

You are trying to display the value of the macro variable BEFORE the data step has had a chance to run and create it. Move your %PUT statement to AFTER the data step.  Also make sure to use the same name in the %PUT as the name you used in the CALL SYMPUTX() call(s).

data _null_;
if &brand_code = 10 then call symputx('comp_name','ABC Company');
else call symputx( 'comp_name', 'XYZ Company');
run;

%put BRAND_CODE = &brand_code ;
%put COMP_NAME = &comp_name ;

 

cnilsen
Quartz | Level 8

that worked...  (I was close.). 

 

Much appreciated to those who offered guidance.!

 

 

- Chris N.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 1113 views
  • 1 like
  • 3 in conversation