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

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 2 replies
  • 408 views
  • 0 likes
  • 2 in conversation