<?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: Create Variables with Do Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592952#M170085</link>
    <description>&lt;P&gt;It is not reallu clear to me what your problem is. The code seems to work fine.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Oct 2019 09:07:17 GMT</pubDate>
    <dc:creator>rudfaden</dc:creator>
    <dc:date>2019-10-01T09:07:17Z</dc:date>
    <item>
      <title>Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592943#M170082</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am stuck with a small problem and I ask for your support.&lt;/P&gt;&lt;P&gt;I need to create a table with 60 columns, the value in each column is based on a date range.&lt;/P&gt;&lt;P&gt;I cannot get it to work.&lt;/P&gt;&lt;P&gt;I have the code&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; work.data_have;&lt;/P&gt;&lt;P&gt;infile datalines delimiter=',';&lt;/P&gt;&lt;P&gt;input issue_date :date9. amount :eurox18.2;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;'13JAN2018'd,4546.77&lt;/P&gt;&lt;P&gt;'08MAR2018'd,117.39&lt;/P&gt;&lt;P&gt;'12JUL2018'd,130.40&lt;/P&gt;&lt;P&gt;'14JUL2018'd,1167.35&lt;/P&gt;&lt;P&gt;'16JUL2018'd,209.96&lt;/P&gt;&lt;P&gt;'17JUL2018'd,0.00&lt;/P&gt;&lt;P&gt;'12JAN2019'd,4854.69&lt;/P&gt;&lt;P&gt;'08MAR2019'd,117.39&lt;/P&gt;&lt;P&gt;'13JUL2019'd,1274.66&lt;/P&gt;&lt;P&gt;'15JUL2019'd,207.41&lt;/P&gt;&lt;P&gt;'26JUL2019'd,113.75&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; work.out_want;&lt;/P&gt;&lt;P&gt;set work.data_have;&lt;/P&gt;&lt;P&gt;array var(&lt;STRONG&gt;60&lt;/STRONG&gt;) var_1 - var_60;&lt;/P&gt;&lt;P&gt;do i=&lt;STRONG&gt;1&lt;/STRONG&gt; to &lt;STRONG&gt;60&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;if (Issue_Date GE intnx('year', (today()- (i)), -&lt;STRONG&gt;1&lt;/STRONG&gt;,'same')) and (Issue_Date LE (TODAY()- (i)) ) = i&lt;/P&gt;&lt;P&gt;then var(i) = Amount;&lt;/P&gt;&lt;P&gt;format var_1 - var_60 eurox18.2;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;drop i;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%let var_i = var_1,var_2,var_3,var_4,var_5,var_6,var_7,var_8,var_9,var_10,&lt;/P&gt;&lt;P&gt;var_11,var_12,var_13,var_14,var_15,var_16,var_17,var_18,var_19,var_20,&lt;/P&gt;&lt;P&gt;var_21,var_22,var_23,var_24,var_25,var_26,var_27,var_28,var_29,var_30,&lt;/P&gt;&lt;P&gt;var_31,var_32,var_33,var_34,var_35,var_36,var_37,var_38,var_39,var_40,&lt;/P&gt;&lt;P&gt;var_41,var_42,var_43,var_44,var_45,var_46,var_47,var_48,var_49,var_50,&lt;/P&gt;&lt;P&gt;var_51,var_52,var_53,var_54,var_55,var_56,var_57,var_58,var_59,var_60;&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Output that I need is shown below:&lt;/P&gt;&lt;P&gt;Everytime the date range select falls in certain {i} it should fill the sum(amount) in the appropriate column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;var_1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_7&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_8&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_9&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_10&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_11&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_12&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4.854,69 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4.854,69 €&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 08:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592943#M170082</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T08:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592952#M170085</link>
      <description>&lt;P&gt;It is not reallu clear to me what your problem is. The code seems to work fine.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:07:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592952#M170085</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2019-10-01T09:07:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592955#M170088</link>
      <description>&lt;P&gt;Please explain the expected result and the difference to what you get right now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I won't open any office-files, so you have to add the relevant information to your post or wait for somebody willing to open the attached docx.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592955#M170088</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2019-10-01T09:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592956#M170089</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;Thank you for your quick response!&lt;/P&gt;&lt;P&gt;The code is working fine, but it does not do what I need... My logic must be wrong...&lt;/P&gt;&lt;P&gt;I need to check every time the difference in Issue Date vs current date - x time and for every match, I need to fill the appropriate column.&lt;/P&gt;&lt;P&gt;like it shows below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;var_1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_4&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_5&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_6&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_7&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_8&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_9&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_10&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_11&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;var_12&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6567,90 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4.854,69 €&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;4.854,69 €&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592956#M170089</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T09:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592957#M170090</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;this is what i need to get:&lt;/P&gt;&lt;P&gt;var_1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_6&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var_8&lt;BR /&gt;6567,90&amp;nbsp; € 6567,90&amp;nbsp; € 6567,90&amp;nbsp; € 6567,90&amp;nbsp;&amp;nbsp; € 6567,90&amp;nbsp;&amp;nbsp; € 6567,90&amp;nbsp; € 6567,90&amp;nbsp; € 6567,90 €&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead I get values only in column var_1...&lt;/P&gt;&lt;P&gt;Every time the date difference matches, I need to put the sum(amount) in the appropriate column var_1.. or 2 or 3 ...&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592957#M170090</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T09:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592962#M170093</link>
      <description>&lt;P&gt;Then you need to change your if statement. It does exactly what you told it to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 09:57:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592962#M170093</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2019-10-01T09:57:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592965#M170096</link>
      <description>&lt;P&gt;Thanks! I knew I had a problem with the logic... can you send me a short helper please?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 10:03:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592965#M170096</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T10:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592969#M170097</link>
      <description>&lt;P&gt;You need to describe what you want the condition to be.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 10:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592969#M170097</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2019-10-01T10:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592972#M170100</link>
      <description>&lt;P&gt;OK,&lt;/P&gt;&lt;P&gt;I need to check the Issue Date through the code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if (Issue_Date GE intnx('year', (today()- (i)), -1,'same')) and (Issue_Date LE (TODAY()- (i)) ) = i&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every time it meets the conditions it should write the amount in the corresponding var_ column.&lt;/P&gt;&lt;P&gt;I need to check it for 60 days, each date separately.&lt;/P&gt;&lt;P&gt;in the example data the amount should be the same for days 1 - 12 (example) so it should write the same amount in columns var_1 through var_12.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 10:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592972#M170100</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T10:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592979#M170106</link>
      <description>&lt;P&gt;I can see that you put an i at the end of the statement.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if (Issue_Date GE intnx('year', (today()- (i)), -1,'same')) and (Issue_Date LE (TODAY()- (i)) ) = i&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is that a mistake?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe you want this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.out_want;
set work.data_have;
array var(60) var_1 - var_60;
do i=1 to 60;
if (Issue_Date GE intnx('year', (today()- (i)), -1,'same')) and (Issue_Date LE (TODAY()- (i)) ) 
then var(i) = Amount;
format var_1 - var_60 eurox18.2;
end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 01 Oct 2019 10:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592979#M170106</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2019-10-01T10:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create Variables with Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592982#M170109</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;YES!&lt;/P&gt;&lt;P&gt;This is what I want!&lt;/P&gt;&lt;P&gt;Thank you very much!!!&lt;/P&gt;</description>
      <pubDate>Tue, 01 Oct 2019 11:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Variables-with-Do-Loop/m-p/592982#M170109</guid>
      <dc:creator>NikosStratis</dc:creator>
      <dc:date>2019-10-01T11:02:36Z</dc:date>
    </item>
  </channel>
</rss>

