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.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: