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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1838 views
  • 1 like
  • 3 in conversation