I am trying to create a prompt that will allow users to pick a variable to summarize on a map. Since the variables will all have different ranges of values, I created a univariate that will group values to summarize by when the project is run. The problem I am having is converting the macro variables I create from the univariate into strings for a proc format statement (the proc format will be used to set the legend values of the map). For example, if &Quant_20 resolves to say 5%, I would like to format the first value of the proc format to read "< 5%" and the next string will be the value between &Quant_20 and &Quant_40.
I think the solution is some kind of %symfunc statement using cats() to join the strings, but either I can't get the double quotes correct or I am going down the wrong path. Below is some sample code. Any help is greatly appreciated!
proc univariate data=calcVar noprint;
var Per_Metric;
output out=Quantile
n=ny mean=meany
pctlpts=0 to 100 by 20
pctlpre=py_;
run;
data _null_;
set Quantile;
call symput ('Quant_20',PY_20);
call symput ('Quant_40',PY_40);
call symput ('Quant_60',PY_60);
call symput ('Quant_80',PY_80);
run;
%put &Quant_20 &Quant_40 &Quant_60 &Quant_80;
proc format;
value Groups
1=&Quant_20.
2=&Quant_40.
3=&Quant_60.
4=&Quant_80.
5=&Quant_20.;
run;
Proc format can take a dataset as inputs, rather than mucking around with macro variables. Look up cntlin= datasets and how to format your dataset.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.