<?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 THEN DO in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956698#M45784</link>
    <description>&lt;P&gt;Thank you.&amp;nbsp; I did exactly what you did in those two if then do statements and got this result (*also did one other step beforehand to put wk00 into wk53 then pushed it to wk_01):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_0-1737407697708.png" style="width: 541px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103862i93C8BAB23234AF17/image-dimensions/541x75?v=v2" width="541" height="75" role="button" title="Deesee_0-1737407697708.png" alt="Deesee_0-1737407697708.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The frequencies look reasonable and the date ranges look fine but for some reason the second row is not showing as "25_wk01" but listed as "25_wk02".&amp;nbsp; The first and third rows are good.&amp;nbsp; I thought the "end" in the if then do stops it from looking further.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;  if year = "2025" and wk1 = "wk00" then do;  
    wk1 = "wk53";  
    wk2 = "24_wk53";  
    year = "2024";  
    mth2 = "12";  
  end;

if year = "2024" and wk1 = "wk53" then do;
                                       wk1 = "wk01"; 
                                       wk2 = "25_wk01";
									   year = "2025";
									   mth2 = "01";
									   end;
if year = "2025" and wk1 = "wk01" then do;
                                       wk1 = "wk02"; 
                                       wk2 = "25_wk02";
									   year = "2025";
									   mth2 = "01";
									   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 20 Jan 2025 21:22:04 GMT</pubDate>
    <dc:creator>Deesee</dc:creator>
    <dc:date>2025-01-20T21:22:04Z</dc:date>
    <item>
      <title>IF THEN DO</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956684#M45776</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_0-1737395232052.png" style="width: 635px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103859iD77440842887365A/image-dimensions/635x425?v=v2" width="635" height="425" role="button" title="Deesee_0-1737395232052.png" alt="Deesee_0-1737395232052.png" /&gt;&lt;/span&gt;&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=""&gt; if year = "2024" and wk1 = "wk53" then do; 
                                        wk1 = "wk01";  
                                        wk2 = "25_wk01"; 
 									   year = "2025"; 
 									   mth2 = "01"; 
 									   end; 

 if year = "2025" and wk1 = "wk00" then do; 
                                        wk1 = "wk01";  
                                        wk2 = "25_wk01"; 
 									   year = "2025"; 
 									   mth2 = "01"; 
 									   end; 
  
 if year = "2025" and wk1 = "wk01" then do; 
                                        wk1 = "wk02";  
                                        wk2 = "25_wk02"; 
 									   year = "2025"; 
 									   mth2 = "01"; 
 									   end; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get this after running the above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_3-1737394887497.png" style="width: 609px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103858iE29AA83F760328B6/image-dimensions/609x108?v=v2" width="609" height="108" role="button" title="Deesee_3-1737394887497.png" alt="Deesee_3-1737394887497.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How do I change the second row to be 25_wk01? Not sure what is wrong with the if then do statements if it produced this result after telling it exactly what to do.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data ip5;
 input  season_yr: $20.
        wbeg: DATE8.
        wend: DATE8.
	wk1: $4.
	wk2 $8.
	year $4.
	year3 $6.
	month3 $6. 
	month33 $3.
	mth2: $2.
	mth3: $6.
datalines;
Yr_24_25,29DEC24,04JAN25,24_wk53,Wk53,2024,2025,202501,JAN
Yr_24_25,29DEC24,04JAN25,25_wk00,Wk00,2025,2025,202501,JAN
Yr_24_25,05JAN25,11JAN25,25_wk01,Wk01,2025,2025,202501,JAN
;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 19:28:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956684#M45776</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T19:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956691#M45781</link>
      <description>&lt;P&gt;Not sure if this is a complete fix, but it's an issue that stands out.&lt;/P&gt;
&lt;P&gt;If your first IF THEN finds a match:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year = "2024" and wk1 = "wk53" then do; 
                                        wk1 = "wk01";  
                                        wk2 = "25_wk01"; 
 									   year = "2025"; 
 									   mth2 = "01"; 
 									   end; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the program doesn't stop.&amp;nbsp; It keeps going through the remaining logic.&amp;nbsp; So the observation that meets the first set of conditions will automatically meet the third set of conditions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if year = "2025" and wk1 = "wk01" then do; 
                                        wk1 = "wk02";  
                                        wk2 = "25_wk02"; 
 									   year = "2025"; 
 									   mth2 = "01"; 
 									   end; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;If that's the issue, you will need to familiarize yourself with ELSE before an IF THEN.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 20:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956691#M45781</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2025-01-20T20:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956698#M45784</link>
      <description>&lt;P&gt;Thank you.&amp;nbsp; I did exactly what you did in those two if then do statements and got this result (*also did one other step beforehand to put wk00 into wk53 then pushed it to wk_01):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_0-1737407697708.png" style="width: 541px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103862i93C8BAB23234AF17/image-dimensions/541x75?v=v2" width="541" height="75" role="button" title="Deesee_0-1737407697708.png" alt="Deesee_0-1737407697708.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The frequencies look reasonable and the date ranges look fine but for some reason the second row is not showing as "25_wk01" but listed as "25_wk02".&amp;nbsp; The first and third rows are good.&amp;nbsp; I thought the "end" in the if then do stops it from looking further.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;  if year = "2025" and wk1 = "wk00" then do;  
    wk1 = "wk53";  
    wk2 = "24_wk53";  
    year = "2024";  
    mth2 = "12";  
  end;

if year = "2024" and wk1 = "wk53" then do;
                                       wk1 = "wk01"; 
                                       wk2 = "25_wk01";
									   year = "2025";
									   mth2 = "01";
									   end;
if year = "2025" and wk1 = "wk01" then do;
                                       wk1 = "wk02"; 
                                       wk2 = "25_wk02";
									   year = "2025";
									   mth2 = "01";
									   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 21:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956698#M45784</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T21:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956701#M45787</link>
      <description>&lt;P&gt;Ok I did the following and it looks like it worked with an else if statement, thank you!!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;if year = "2024" and wk1 = "wk53" then do;
                                       wk1 = "wk01"; 
                                       wk2 = "25_wk01";
									   year = "2025";
									   mth2 = "01";
									   end;
else 

if year = "2025" and wk1 = "wk01" then do;
                                       wk1 = "wk02"; 
                                       wk2 = "25_wk02";
									   year = "2025";
									   mth2 = "01";
									   end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 22:23:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO/m-p/956701#M45787</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T22:23:42Z</dc:date>
    </item>
  </channel>
</rss>

