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!.
TITLE needs a quoted string
title1 "&startdate to &enddate";
title2 "&comp_name";
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?
Pay close attention to my code. The variable name is comp_name (note the underline!).
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 ;
that worked... (I was close.).
Much appreciated to those who offered guidance.!
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!
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.
Ready to level-up your skills? Choose your own adventure.