BookmarkSubscribeRSS Feed
P5C768
Obsidian | Level 7

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;

1 REPLY 1
Reeza
Super User

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.

http://www2.sas.com/proceedings/forum2007/068-2007.pdf

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

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
  • 1 reply
  • 1028 views
  • 0 likes
  • 2 in conversation