DATA Step, Macro, Functions and more

Create String for Proc Format from Macro Variables

Reply
Frequent Contributor
Posts: 84

Create String for Proc Format from Macro Variables

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;

Super User
Posts: 17,960

Re: Create String for Proc Format from Macro Variables

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

Ask a Question
Discussion stats
  • 1 reply
  • 183 views
  • 0 likes
  • 2 in conversation