<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Select Number of Levels from a Format into Macro Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682587#M206620</link>
    <description>&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC FORMAT;
	VALUE RANKS
		0="0"
		1="1"
		&amp;amp;&amp;amp;VAL_&amp;amp;H.-HIGH ="More than &amp;amp;&amp;amp;VAL_&amp;amp;H."
		%MACRO MAKE_F (HOWMANY);
			%DO I=1 %TO &amp;amp;HOWMANY.;
				%LET K=%EVAL(&amp;amp;I.+1);
					&amp;amp;&amp;amp;VAL_&amp;amp;I. - %EVAL(&amp;amp;&amp;amp;VAL_&amp;amp;K.-1)="&amp;amp;&amp;amp;VAL_&amp;amp;I. TO %EVAL(&amp;amp;&amp;amp;VAL_&amp;amp;K.-1)"
			%END;
		%MEND MAKE_F;
			%MAKE_F (%EVAL(&amp;amp;H.-1));
	RUN;
%INCLUDE "&amp;amp;PATH.\PROGRAMS\MACRO\COLOR_SCALE.SAS";
%COLORSCALE(AFD5E8,,CA5B5C, 10, ANNO);&lt;/PRE&gt;</description>
    <pubDate>Wed, 09 Sep 2020 11:54:37 GMT</pubDate>
    <dc:creator>dandy_jim</dc:creator>
    <dc:date>2020-09-09T11:54:37Z</dc:date>
    <item>
      <title>Select Number of Levels from a Format into Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682587#M206620</link>
      <description>&lt;P&gt;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!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;PROC FORMAT;
	VALUE RANKS
		0="0"
		1="1"
		&amp;amp;&amp;amp;VAL_&amp;amp;H.-HIGH ="More than &amp;amp;&amp;amp;VAL_&amp;amp;H."
		%MACRO MAKE_F (HOWMANY);
			%DO I=1 %TO &amp;amp;HOWMANY.;
				%LET K=%EVAL(&amp;amp;I.+1);
					&amp;amp;&amp;amp;VAL_&amp;amp;I. - %EVAL(&amp;amp;&amp;amp;VAL_&amp;amp;K.-1)="&amp;amp;&amp;amp;VAL_&amp;amp;I. TO %EVAL(&amp;amp;&amp;amp;VAL_&amp;amp;K.-1)"
			%END;
		%MEND MAKE_F;
			%MAKE_F (%EVAL(&amp;amp;H.-1));
	RUN;
%INCLUDE "&amp;amp;PATH.\PROGRAMS\MACRO\COLOR_SCALE.SAS";
%COLORSCALE(AFD5E8,,CA5B5C, 10, ANNO);&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Sep 2020 11:54:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682587#M206620</guid>
      <dc:creator>dandy_jim</dc:creator>
      <dc:date>2020-09-09T11:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Select Number of Levels from a Format into Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682631#M206633</link>
      <description>&lt;P&gt;My first idea: write the format to a CNTLOUT= dataset and do a COUNT(*) on it.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 13:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682631#M206633</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-09T13:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Select Number of Levels from a Format into Macro Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682643#M206638</link>
      <description>&lt;P&gt;Thank you, Kurt. That worked well. I was not aware of that function.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 14:10:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Select-Number-of-Levels-from-a-Format-into-Macro-Variable/m-p/682643#M206638</guid>
      <dc:creator>dandy_jim</dc:creator>
      <dc:date>2020-09-09T14:10:27Z</dc:date>
    </item>
  </channel>
</rss>

