<?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: struggeling with sqplot in a loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330906#M74313</link>
    <description>&lt;P&gt;Do you want a plot for each user or a plot in a separate file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is common when using a Call Execute approach to have a control data set with the key values, such as your name variable.&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set control;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;lt;call execute statements&amp;gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then the value of the NAME can be pulled from the control data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also if your list of names is small enough SAS allows using Character values in do loops.&lt;/P&gt;
&lt;P&gt;do name='John', 'Roy','David';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;use name as you used i in the year example&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Feb 2017 16:45:58 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-02-08T16:45:58Z</dc:date>
    <item>
      <title>struggeling with sqplot in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330882#M74304</link>
      <description>&lt;P&gt;I have been struggling with producing SGPLOT for every user in my dataset.&lt;/P&gt;&lt;P&gt;Let's say this is the data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test;
	input user $ event number;
	datalines;
	John 1 100
	John 2 150
	John 3 200
	Roy 1 200
	Roy 2 250
	Roy 3 300
	David 1 600
	David 2 150
	David 3 800
;
run;&lt;/PRE&gt;&lt;P&gt;The idea is to produce a pdf with a bar chart for every user.&lt;/P&gt;&lt;P&gt;I have found an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; test&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;year&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;month&lt;/SPAN&gt; air&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;	&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;	1949 1 100
	1949 2 150
	1949 3 200
	1950 1 200
	1950 2 250
	1950 3 300
	1951 1 600
	1951 2 150
	1951 3 800&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;data _null_;
  do i=1949 to 1955;
    call execute(cats('ods pdf file="c:\year_',put(i,4.),'.pdf";));&lt;BR /&gt;    call execute(cats('title "',put(i,4.),'";'));
    call execute(cats('proc sgplot data=test (where=(year=',put(i,4.),')); vbar month/response=air; run;'));
    call execute('ods pdf close;');
  end;
run;&lt;/PRE&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;But in my case there is no column which could be used to run the loop on. I can obviously add one, but the reference for the file name and plot data should be the name of the user, not the loop column.&lt;/P&gt;&lt;P&gt;It's probably not that difficult but I just don't see it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:10:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330882#M74304</guid>
      <dc:creator>fsdfs</dc:creator>
      <dc:date>2017-02-08T16:10:50Z</dc:date>
    </item>
    <item>
      <title>Re: struggeling with sqplot in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330906#M74313</link>
      <description>&lt;P&gt;Do you want a plot for each user or a plot in a separate file?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is common when using a Call Execute approach to have a control data set with the key values, such as your name variable.&lt;/P&gt;
&lt;P&gt;Data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set control;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;lt;call execute statements&amp;gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then the value of the NAME can be pulled from the control data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also if your list of names is small enough SAS allows using Character values in do loops.&lt;/P&gt;
&lt;P&gt;do name='John', 'Roy','David';&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;use name as you used i in the year example&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:45:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330906#M74313</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-02-08T16:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: struggeling with sqplot in a loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330909#M74316</link>
      <description>&lt;P&gt;I have to assume you can put the SGPLOT code into play, using CALL EXECUTE.&amp;nbsp; Here's how you get the loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;data _null_;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;do until (last.user);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; set test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; by user;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;end;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;call execute('data subset; set test; where user="' );&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;call execute(user);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;call execute('"; run;');&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;** More CALL EXECUTES to generate the SGPLOT using the data set SUBSET;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The top portion of the DATA step generates a subset of the TEST data (named SUBSET) for a single user.&amp;nbsp; Then the next part that you add will generate SGPLOT and related statements for that user.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2017 16:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/struggeling-with-sqplot-in-a-loop/m-p/330909#M74316</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-02-08T16:52:20Z</dc:date>
    </item>
  </channel>
</rss>

