BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dandy_jim
Calcite | Level 5

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);
1 ACCEPTED SOLUTION
2 REPLIES 2

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 527 views
  • 0 likes
  • 2 in conversation