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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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