<?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: Loop thru values in a data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/278009#M55902</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your were correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was so close &lt;STRONG&gt;(and yet soooo far)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have no idea how long I have been struggling with this simple thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kody_Devl&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jun 2016 19:06:00 GMT</pubDate>
    <dc:creator>Kody_devl</dc:creator>
    <dc:date>2016-06-16T19:06:00Z</dc:date>
    <item>
      <title>Loop thru values in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/277955#M55877</link>
      <description>&lt;P&gt;I am an experienced developer in everthing but SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a Dataset ---&amp;gt;&amp;nbsp;&amp;nbsp; "Periods" with a single column and 12 periods:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;YYYYPP&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;201605&lt;/P&gt;&lt;P&gt;201604&lt;/P&gt;&lt;P&gt;201603&lt;/P&gt;&lt;P&gt;201602&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want step thru each data format in the Periods table, run an query to pull based on each of the 12 dates,&amp;nbsp;by setting the current period equal to a variable and using the variable as criteria for the pull.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can do all parts of this except the looping part of the code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my approach and I can't get it to work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;macro1&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%Do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%To&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;12&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%By&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; symputx (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'YYYYPP'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;,trim(YYYYPP));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;RunQuery using &amp;amp;YYYYPP.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%Mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; macro1; %&lt;STRONG&gt;&lt;I&gt;macro1&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Any Help is appreciated in advance.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:18:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/277955#M55877</guid>
      <dc:creator>Kody_devl</dc:creator>
      <dc:date>2016-06-16T16:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loop thru values in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/277968#M55884</link>
      <description>&lt;P&gt;You're moving in the right direction.&amp;nbsp; Add a semicolon at the end of the %END statement, and embellish on the CALL SYMPUTX line to make it a full DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set have (obs=&amp;amp;i firstobs=&amp;amp;i);&lt;/P&gt;
&lt;P&gt;call symputx('YYYYPP', yyyypp);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With CALL SYMPUTX, the TRIM function is not needed.&amp;nbsp; Leading and trailing blanks are automatically removed.&amp;nbsp; In fact, CALL SYMPUTX will even work properly if your incoming variable is numeric instead of character.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Net result:&amp;nbsp; &amp;amp;YYYYPP gets updated each time through the loop, and is available for your query.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 16:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/277968#M55884</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-16T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Loop thru values in a data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/278009#M55902</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your were correct.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was so close &lt;STRONG&gt;(and yet soooo far)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have no idea how long I have been struggling with this simple thing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;THANK YOU!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kody_Devl&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 19:06:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-thru-values-in-a-data-set/m-p/278009#M55902</guid>
      <dc:creator>Kody_devl</dc:creator>
      <dc:date>2016-06-16T19:06:00Z</dc:date>
    </item>
  </channel>
</rss>

