<?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 Re: How to show multiple reference lines with varied colors based &amp;quot;the max/min flag&amp;quot;?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976424#M378322</link>
    <description>Anyone can help？</description>
    <pubDate>Sun, 05 Oct 2025 14:31:41 GMT</pubDate>
    <dc:creator>hellohere</dc:creator>
    <dc:date>2025-10-05T14:31:41Z</dc:date>
    <item>
      <title>How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976418#M378316</link>
      <description>&lt;P&gt;I am getting regional maxs/mins where to set reference lines (axis=x). I need show the reference lines with two diff. colors (Max-&amp;gt; Blue; Min -&amp;gt; Cyan).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sample code is below. Used additional dataset is fine, such as&amp;nbsp;_test_mm_ind.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _test;
do i=1 to 300;
	tsvar=sin(i/10); output;
end;
run;quit;

	proc sgplot data=_test(where=(i between 150 and 450));
	series x=i y=tsvar /lineattrs=(color=red thickness=2 pattern=solid);   
	run;quit;

	proc sql noprint;
	select i into: _ref_1 from _test where i between   	10 and   20 having tsvar=max(tsvar);
	select i into: _ref_2 from _test where i between    40 and   60 having tsvar=min(tsvar);
	select i into: _ref_3 from _test where i between   	70 and   90 having tsvar=max(tsvar);
	select i into: _ref_4 from _test where i between   100 and  120 having tsvar=min(tsvar);
	select i into: _ref_5 from _test where i between   130 and  150 having tsvar=max(tsvar);
	select i into: _ref_6 from _test where i between   160 and  180 having tsvar=min(tsvar);
	select i into: _ref_7 from _test where i between   200 and  220 having tsvar=max(tsvar);
	select i into: _ref_8 from _test where i between   220 and  240 having tsvar=min(tsvar);
	select i into: _ref_9 from _test where i between   260 and  280 having tsvar=max(tsvar);
	quit;

	proc sgplot data=_test(where=(i between 00 and 14000));
	series x=i y=tsvar /lineattrs=(color=red thickness=2 pattern=solid); 
	refline  &amp;amp;_ref_1./axis=x lineattrs=(color=blue thickness=2 pattern=solid); 
 	refline  &amp;amp;_ref_2./axis=x;
	refline  &amp;amp;_ref_3./axis=x;
	refline  &amp;amp;_ref_4./axis=x;
	refline  &amp;amp;_ref_5./axis=x;
	refline  &amp;amp;_ref_6./axis=x;
	refline  &amp;amp;_ref_7./axis=x;
	refline  &amp;amp;_ref_8./axis=x;
	refline  &amp;amp;_ref_9./axis=x;
	run;quit;

	%let mvars=&amp;amp;_ref_1.@&amp;amp;_ref_2.@&amp;amp;_ref_3.@&amp;amp;_ref_4.@&amp;amp;_ref_5.@&amp;amp;_ref_6.@&amp;amp;_ref_7.@&amp;amp;_ref_8.@&amp;amp;_ref_9.;
    %let mvars2=max@min@max@min@max@min@max@min@max;

	data _test_mm_ind;
	do i= 1 to countw(symget('mvars'),'@');
		length mm_indx note $8. ;
			mm_indx=scan(symget('mvars'),i,'@');
			note=scan(symget('mvars2'),i,'@');
		output;
	end;
	run;quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Oct 2025 11:33:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976418#M378316</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-05T11:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976424#M378322</link>
      <description>Anyone can help？</description>
      <pubDate>Sun, 05 Oct 2025 14:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976424#M378322</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-05T14:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976428#M378326</link>
      <description>&lt;P&gt;Nowhere in your code do you ask for a CYAN colored line.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This should work, I'm too lazy to fix all of your lines, I only fixed one line, you can fix the rest of the lines as needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; 	refline  &amp;amp;_ref_2./axis=x lineattrs=(color=cyan thickness=2 pattern=solid);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, it not clear what the data set named&amp;nbsp;_test_mm_ind has to do with anything. You included it without giving an explanation of what it does or why it is important.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 16:23:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976428#M378326</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-10-05T16:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976431#M378329</link>
      <description>&lt;P&gt;It's next to impossible to tell what you're trying to do here or what question it is that you're asking.&amp;nbsp; The first DATA step has i from 1 to 300.&amp;nbsp; Then there's an SGPLOT that reads that dataset from i=150 to 450.&amp;nbsp; Then there's a SQL step that has inconsistent ranges - some have a gap of 20 between the &lt;EM&gt;max&lt;/EM&gt; of gap(n) and the &lt;EM&gt;min&lt;/EM&gt; of gap(n+1), some have a gap of 10, some have a gap of zero.&amp;nbsp; That matters because it appears (in the next SGPLOT) that you're planning to extend this to 14000, so really you need a macro, an array solution, or something else to be able to do that in a sane way, and there's no way for anyone to help you without understanding the pattern of the ranges you're looking for.&amp;nbsp; Then, in the final step, which, like Paige Miller, I am also baffled by, you're reading the macro variables you just created from the first dataset back into another dataset -- is this supposed to be an "annotate"&amp;nbsp;dataset used by SGPLOT?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 18:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976431#M378329</guid>
      <dc:creator>quickbluefish</dc:creator>
      <dc:date>2025-10-05T18:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976433#M378330</link>
      <description>&lt;P&gt;I agree with QBF, there are a lot of things in your code and problem statement that either don't make sense, or need a lot more explanation, or raise eyebrows. I'm not at all sure your question is the one I gave a solution for — is the problem really that you want cyan lines but you never told SAS to draw a cyan line? I think it would be a positive thing to re-write this whole problem statement with a goal of making it much clearer. And don't make the mistake of assuming that we know what you are doing or we can figure out what you are doing, because as I said, I have no idea what data set&amp;nbsp;_test_mm_ind is doing or why it is even included.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 20:58:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976433#M378330</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-10-05T20:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976434#M378331</link>
      <description>sample code .... 

i need collect the max/min for later macro loop.</description>
      <pubDate>Sun, 05 Oct 2025 21:51:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976434#M378331</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-05T21:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976435#M378332</link>
      <description>&lt;P&gt;Nice fix.&amp;nbsp; What if here is 100 max/min?! Close to your daily?!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 21:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976435#M378332</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-05T21:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976436#M378333</link>
      <description>&lt;P&gt;Before trying to use macro code and macro variables to generate code make sure you know what code you want to generate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you provide a simple example with 2 or three reference lines without any macro variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then explain what parts of the code needs to vary.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you sure you need to use code generation to produce the graph you want?&amp;nbsp; If you could explain the graph, perhaps include a picture of what you want it look like, then perhaps there is a way to make it directly from a dataset (or multiple datasets) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also can you explain what the graph represents?&amp;nbsp; Perhaps SAS already has a procedure to produce the graph you want.&lt;/P&gt;</description>
      <pubDate>Sun, 05 Oct 2025 22:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976436#M378333</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-10-05T22:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to show multiple reference lines with varied colors based "the max/min flag"?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976439#M378335</link>
      <description>ignore this thread. I started a new one.</description>
      <pubDate>Mon, 06 Oct 2025 03:53:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-show-multiple-reference-lines-with-varied-colors-based/m-p/976439#M378335</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-10-06T03:53:51Z</dc:date>
    </item>
  </channel>
</rss>

