<?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: Use var from have in do loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388950#M93264</link>
    <description>&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your comments. The problem statement has changed since original posting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem statement: generate series of line plots from 4&amp;nbsp;variables.&lt;/P&gt;&lt;P&gt;Source: have is 1 table with the 4&amp;nbsp;variables of interest:&lt;/P&gt;&lt;P&gt;VehNo is integer&lt;/P&gt;&lt;P&gt;FaultNo is integer&lt;/P&gt;&lt;P&gt;stat is float&lt;/P&gt;&lt;P&gt;date is dt format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output will be line plots of stat vs date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typical loop that calls a line plot macro follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for i = 1:dim(VehNo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;for j = 1:dim(FaultNo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; call line_plot_macro(&lt;SPAN&gt;VehNo(i),FaultNo(j))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;end j&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;end i&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The macro will access&amp;nbsp;the&amp;nbsp;data. The macro will organize and plot the stats by occurance date from the&amp;nbsp;instances of a specific fault for a specific vehicle.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Initially there should be in the neighborhood of 100 plots which will increase as data is collected.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can probably get the line plot macro by modifying code generated by the line plot wizard.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this is clearer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;capam&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2017 19:58:42 GMT</pubDate>
    <dc:creator>capam</dc:creator>
    <dc:date>2017-08-17T19:58:42Z</dc:date>
    <item>
      <title>Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388914#M93257</link>
      <description>&lt;P&gt;I'm attempting to access a variable in have for calling a macro from a do loop. When I try the following code I get errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The DIM, LBOUND, and HBOUND functions require an array name for the first argument.&lt;/P&gt;&lt;P&gt;ERROR 68-185: The function Var_in_have is unknown, or cannot be accessed.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	call execute('proc sql;');

	do i=1 to dim(Var_in_have) while (Var_in_have(i) ne .);
		call execute(cats('%nrstr(%some_macro)(',Var_in_have(i),')'));
	end;

	call execute('quit;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:53:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388914#M93257</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-17T17:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388928#M93259</link>
      <description>&lt;P&gt;You don't have a SET statement so you aren't using any data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Build your string outside of CALL EXECUTE and check what it's generating first. Then pass the string to CALL EXECUTE.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my experience, you don't usually need the %nrstr() when using CALL EXECUTE unless there's something you need to mask.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388928#M93259</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T18:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388935#M93262</link>
      <description>&lt;P&gt;There are bright red &lt;FONT color="#ff0000"&gt;DANGER&lt;/FONT&gt; signs throughout your post that indicate you should not be doing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to understand SAS language for macro language to be useful.&amp;nbsp; Macro language does not process your data.&amp;nbsp; It builds a program by generating working SAS statements.&amp;nbsp; You are not ready for this yet.&amp;nbsp; Here are just a few examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your message indicates that you think you are using data from the data set HAVE.&amp;nbsp; You're not.&amp;nbsp; There is nothing about your program that reads from an existing SAS data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You use the DIM function to refer to an array named Var_in_have.&amp;nbsp; There is no such array.&amp;nbsp; If you did have such an array, it would seem that it should contain names of variables.&amp;nbsp; The reference to "ne ." would be incorrect for referring to a missing value for the name of a variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your intent seems to be to run a macro for every variable.&amp;nbsp; While that's possible, it's extremely unlikely that the same macro would be useful for both character and numeric variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would do better to describe your original data and what you are trying to accomplish.&amp;nbsp; You could get answers here, possibly very simple answers.&amp;nbsp; The answers may or may not include macro language (depending on the goal).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 18:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388935#M93262</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-17T18:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388950#M93264</link>
      <description>&lt;P&gt;Hi Astounding,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your comments. The problem statement has changed since original posting.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Problem statement: generate series of line plots from 4&amp;nbsp;variables.&lt;/P&gt;&lt;P&gt;Source: have is 1 table with the 4&amp;nbsp;variables of interest:&lt;/P&gt;&lt;P&gt;VehNo is integer&lt;/P&gt;&lt;P&gt;FaultNo is integer&lt;/P&gt;&lt;P&gt;stat is float&lt;/P&gt;&lt;P&gt;date is dt format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output will be line plots of stat vs date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Typical loop that calls a line plot macro follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for i = 1:dim(VehNo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;for j = 1:dim(FaultNo)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; call line_plot_macro(&lt;SPAN&gt;VehNo(i),FaultNo(j))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;end j&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;end i&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The macro will access&amp;nbsp;the&amp;nbsp;data. The macro will organize and plot the stats by occurance date from the&amp;nbsp;instances of a specific fault for a specific vehicle.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Initially there should be in the neighborhood of 100 plots which will increase as data is collected.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I can probably get the line plot macro by modifying code generated by the line plot wizard.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope this is clearer.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;capam&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 19:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388950#M93264</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2017-08-17T19:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388955#M93265</link>
      <description>&lt;P&gt;Yes, you will need the code from the wizard, so you can plug it into a program.&amp;nbsp; If you are looking to get a separate plot for each combination of values that VEHNO and FAULTNO take on, it sounds like you need this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have;&lt;/P&gt;
&lt;P&gt;by VehNo FaultNo;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc plot /* or sgplot or whatever the wizard tells&amp;nbsp; you to use */ data=have;&lt;/P&gt;
&lt;P&gt;by VehNo FaultNo;&lt;/P&gt;
&lt;P&gt;*** Add the rest of the code from the wizard;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 20:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388955#M93265</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-08-17T20:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Use var from have in do loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388994#M93266</link>
      <description>&lt;P&gt;You may want to look into a completely different approach the Graph Templat Language let's you do some pretty interesting things and I think it is much more straight forward then what it looks like you are attempting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/41/367.html" target="_blank"&gt;http://support.sas.com/kb/41/367.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/39/099.html" target="_blank"&gt;http://support.sas.com/kb/39/099.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/39/092.html" target="_blank"&gt;http://support.sas.com/kb/39/092.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All show different groupings of series charts. Go the Results tabl on the page to see the graph, the Full code will have code to generate the graph.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 22:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-var-from-have-in-do-loop/m-p/388994#M93266</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-17T22:50:44Z</dc:date>
    </item>
  </channel>
</rss>

