<?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: IF statements array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699518#M213993</link>
    <description>&lt;P&gt;Use the INDSNAME= option of the SET statement instead of the multiple IN= dataset options.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Nov 2020 14:40:24 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-11-17T14:40:24Z</dc:date>
    <item>
      <title>IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699507#M213988</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;What is the way to write the following statements in array?&lt;/P&gt;
&lt;P&gt;It should be a flexible program?&lt;/P&gt;
&lt;P&gt;The user define dates that he is interested (vector macro parameter)&lt;/P&gt;
&lt;P&gt;Then the program is working by these dates.&lt;/P&gt;
&lt;P&gt;In the example show below the user defined 5 dates so should have 5 statements .&lt;/P&gt;
&lt;P&gt;But in another case user might choose for example 3 dates and then need only 3 statements&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;IF S1 then YYMM_source=&amp;amp;m1;&lt;BR /&gt;IF S2 then YYMM_source=&amp;amp;m2;&lt;BR /&gt;IF S3 then YYMM_source=&amp;amp;m3;&lt;BR /&gt;IF S4 then YYMM_source=&amp;amp;m4;&lt;BR /&gt;IF S5 then YYMM_source=&amp;amp;m5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data ttt2009;
input id z w y;
cards;
1 9 0 10
2 9 0 20
3 8 0 30
;
run;
Data ttt2006;
input id z w y;
cards;
1 9 0 12
2 9 0 23
3 8 0 34
;
run;
Data ttt2003;
input id z w y;
cards;
1 9 0 54
2 9 0 23
3 8 0 42
;
run;
Data ttt1912;
input id z w y;
cards;
1 9 0 17
2 9 0 54
3 8 0 26
;
run;
Data ttt1909;
input id z w y;
cards;
1 9 0 34
2 9 0 16
3 8 0 43
;
run;
Data ttt1906;
input id z w y;
cards;
1 9 0 34
2 9 0 19
3 8 0 25
;
run;
Data ttt1903;
input id z w y;
cards;
1 9 0 34
2 9 0 25
3 8 0 18
;
run;

%let vector=2009+2006+2003+1912+1909;

%let n =%sysfunc(countw(&amp;amp;vector));
%put &amp;amp;n;


/*%put &amp;amp;m1;*/
/*%put &amp;amp;m2;*/
/*%put &amp;amp;m3;*/
/*%put &amp;amp;m4;*/
/*%put &amp;amp;m5;*/
%macro sset; 
%do j=1 %to &amp;amp;n.;
ttt&amp;amp;&amp;amp;m&amp;amp;j.. (where=(Z=9 and W=0)in=S&amp;amp;j.)
%end;
%mend;
%put %sset;


Data tbl_all;
set %sset;
by ID;
/*Check how do it automatically???*/
IF S1 then YYMM_source=&amp;amp;m1;
IF S2 then YYMM_source=&amp;amp;m2;
IF S3 then YYMM_source=&amp;amp;m3;
IF S4 then YYMM_source=&amp;amp;m4;
IF S5 then YYMM_source=&amp;amp;m5;
Run;
 
    &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Nov 2020 14:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699507#M213988</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-11-17T14:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699516#M213991</link>
      <description>&lt;P&gt;You may want to read the documentation of the set statement, especially the indsname-option seems to useful to solve the problem.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 14:37:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699516#M213991</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-11-17T14:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699517#M213992</link>
      <description>&lt;P&gt;This whole problem becomes incredibly easy if you don't put calendar year/month into data set names or variable names. Use one long data set, with a variable to indicate the year and month, and the problem is much much easier.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 14:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699517#M213992</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-11-17T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699518#M213993</link>
      <description>&lt;P&gt;Use the INDSNAME= option of the SET statement instead of the multiple IN= dataset options.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Nov 2020 14:40:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699518#M213993</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-17T14:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699677#M214037</link>
      <description>&lt;P&gt;It is perfect , I am still interested to know if it is possible to write the IF's statements using macro or array?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data tbl_all;
set %sset  indsname=ds;
by ID;
YYMM_source=substr(scan(ds,2,'.'),4);
Run;
/*WORK.TTT2009 */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 18 Nov 2020 06:11:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699677#M214037</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-11-18T06:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699678#M214038</link>
      <description>This is true but let's say that this structure is not defined by me and I see it as the status that I need to work with</description>
      <pubDate>Wed, 18 Nov 2020 06:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699678#M214038</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-11-18T06:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: IF statements array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699682#M214040</link>
      <description>&lt;P&gt;What is contained in macro variables m1 to m5 in your original example?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 06:53:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IF-statements-array/m-p/699682#M214040</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-11-18T06:53:03Z</dc:date>
    </item>
  </channel>
</rss>

