I am somewhat new to data driven formatting but sort of winging it. I have defined a format based on modified proc univariate output. The number of levels in the format is later used to select the number of intermediate colors in a gradient created with the color select macro. Is there a way to select the number of levels in a user defined format into a macro variable? I would like this to remain flexible so I would prefer to pull from the meta-data rather than manually count the number of levels defined (as is done now with the 10 argument in color-scale). I checked the formats dictionary table and there does not appear to be a variable corresponding to the number of levels in the format. Snippet of code below, thanks!
PROC FORMAT; VALUE RANKS 0="0" 1="1" &&VAL_&H.-HIGH ="More than &&VAL_&H." %MACRO MAKE_F (HOWMANY); %DO I=1 %TO &HOWMANY.; %LET K=%EVAL(&I.+1); &&VAL_&I. - %EVAL(&&VAL_&K.-1)="&&VAL_&I. TO %EVAL(&&VAL_&K.-1)" %END; %MEND MAKE_F; %MAKE_F (%EVAL(&H.-1)); RUN; %INCLUDE "&PATH.\PROGRAMS\MACRO\COLOR_SCALE.SAS"; %COLORSCALE(AFD5E8,,CA5B5C, 10, ANNO);
My first idea: write the format to a CNTLOUT= dataset and do a COUNT(*) on it.
My first idea: write the format to a CNTLOUT= dataset and do a COUNT(*) on it.
Thank you, Kurt. That worked well. I was not aware of that function.
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 save with the early bird rate—just $795!
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.