<?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: Array to loop column name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316162#M69052</link>
    <description>&lt;P&gt;Don't put data in structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead assign the date to a variable month_end, the value to a properly named variable, and do a output for every single calculation.&lt;/P&gt;
&lt;P&gt;This also resolves the issue of having to use the execrable 'some garbage goes in here'n construct for variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
format month_end date9.;
do month = 4 to 9;
  month_end = intnx('month',mdy(month,1,2016),0,'end');
  value = min(base_pre,max(0,((month_end-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Dec 2016 08:45:12 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-12-02T08:45:12Z</dc:date>
    <item>
      <title>Array to loop column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316152#M69044</link>
      <description>&lt;P&gt;Hi team,&lt;/P&gt;&lt;P&gt;Please kindly help me on this logic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this is my sample code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test_data;&lt;BR /&gt;set Final_Data_IPAS_PR_Claims;&lt;BR /&gt;&lt;FONT color="#FF6600"&gt;'28FEB2014'n&lt;/FONT&gt;= min(base_pre,max(0,((&lt;FONT color="#FF6600"&gt;19782&lt;/FONT&gt;-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));&lt;/P&gt;&lt;P&gt;'&lt;FONT color="#FF6600"&gt;31MAR2014&lt;/FONT&gt;'n= min(base_pre,max(0,((&lt;FONT color="#FF6600"&gt;19813&lt;/FONT&gt;-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));&lt;BR /&gt;'&lt;FONT color="#FF6600"&gt;30APR2014&lt;/FONT&gt;'n= min(base_pre,max(0,((&lt;FONT color="#FF6600"&gt;19843&lt;/FONT&gt;-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));&lt;BR /&gt;'&lt;FONT color="#FF6600"&gt;31MAY2014&lt;/FONT&gt;'n= min(base_pre,max(0,((&lt;FONT color="#FF6600"&gt;19874&lt;/FONT&gt;-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));&lt;BR /&gt;'&lt;FONT color="#FF6600"&gt;30JUN2014&lt;/FONT&gt;'n= min(base_pre,max(0,((&lt;FONT color="#FF6600"&gt;19904&lt;/FONT&gt;-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing this manally, with many steps i need some array and loop combination to get it right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need some logic to create the month end date as column names from &lt;FONT color="#FF6600"&gt;30APR2014&lt;/FONT&gt; to &lt;FONT color="#FF6600"&gt;SEP2016&amp;nbsp;&lt;FONT color="#000000"&gt;and the numeric value of the particular coulumn should be used in the condition.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF6600"&gt;&lt;FONT color="#000000"&gt;Logic is same across all the columns created. Just i need to change the numeric value highlighted in the formula according to the column date. (Means the numeric value of the month end date should be used there)..&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 07:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316152#M69044</guid>
      <dc:creator>SBRVamsi</dc:creator>
      <dc:date>2016-12-02T07:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: Array to loop column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316162#M69052</link>
      <description>&lt;P&gt;Don't put data in structure.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead assign the date to a variable month_end, the value to a properly named variable, and do a output for every single calculation.&lt;/P&gt;
&lt;P&gt;This also resolves the issue of having to use the execrable 'some garbage goes in here'n construct for variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
format month_end date9.;
do month = 4 to 9;
  month_end = intnx('month',mdy(month,1,2016),0,'end');
  value = min(base_pre,max(0,((month_end-'Policy Start Date'n+1)/(Policy_Term*365)*base_pre)));
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 08:45:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316162#M69052</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-12-02T08:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Array to loop column name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316166#M69054</link>
      <description>&lt;P&gt;I developed a code to do the work - see ttached file.&lt;/P&gt;
&lt;P&gt;The code generates a program in a directory as defined in first line - FILENAME statement.&lt;/P&gt;
&lt;P&gt;Adapt the filename to your instalation.&lt;/P&gt;
&lt;P&gt;To run the generated program add at end the line:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;%include pgm;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For test I looped from FEB 2014 to FEB 2015;&lt;/P&gt;
&lt;P&gt;Addapt required dates on lines: 4, 5, 13.&lt;/P&gt;
&lt;P&gt;It can be done dynamicaly if you put the code into a macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro create(y_start, m_start, y_end, m_end);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/* copy the code here and change lines: */&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; /* line 4 */ &amp;nbsp;&lt;STRONG&gt;y1 = &amp;amp;y_start;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; /* line 5 */ &lt;STRONG&gt;m1 = &amp;amp;m_start;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; /* line 13 */ &amp;nbsp;&lt;STRONG&gt;do until(y1 = &amp;amp;y_end and m1 = &amp;amp;m_end);&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;%mend create;&lt;/P&gt;
&lt;P&gt;%create (2014, 02, 2016, 09);&lt;/P&gt;
&lt;P&gt;%include pgm;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Dec 2016 08:51:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Array-to-loop-column-name/m-p/316166#M69054</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-12-02T08:51:57Z</dc:date>
    </item>
  </channel>
</rss>

