<?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 - Issues in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956700#M45786</link>
    <description>Yes that is fine. It shouldnt be mixed case it's lower case.</description>
    <pubDate>Mon, 20 Jan 2025 21:37:01 GMT</pubDate>
    <dc:creator>Deesee</dc:creator>
    <dc:date>2025-01-20T21:37:01Z</dc:date>
    <item>
      <title>IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956627#M45767</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_0-1737345995996.png" style="width: 871px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103844iA92D999F00468AAD/image-dimensions/871x601?v=v2" width="871" height="601" role="button" title="Deesee_0-1737345995996.png" alt="Deesee_0-1737345995996.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data _null_;
format dt date9.;
dt='16JAN2025'D;
call symput('currmo', compress(put(year(dt),z4.))||compress(put(month(dt),z2.)));
run;
%put CURRMO = &amp;amp;currmo.;


data ip;

  options compress=yes;  
  set mixed;  
  
  /* Define formats */  
  format wbeg wend mbeg mend date8.;  
  format AdmitDt  mmddyy10.; 
 
  
  /* Calculate month and week limits */  
  mbeg = intnx('month', AdmitDt, 0, 'b');  
  mend = intnx('month', AdmitDt, 0, 'e');  
  wbeg = intnx('week', AdmitDt, 0, 'b');  
  wend = intnx('week', AdmitDt, 0, 'e');  
  madm = month(AdmitDt);  
  mwbeg = month(wbeg);  
  mwend = month(wend);  
  
  /* Determine the month3 value */  
if month(wbeg) = month(wend) then do;
                                  month3 = put(year(AdmitDt),4.)||put(month(AdmitDt),z2.);
                                  end;
else if mend - wbeg &amp;lt; 7 then do;
                                if mend - wbeg &amp;lt; 3 then do;
							                            if month(AdmitDt) = 12 then month3 = put(year(AdmitDt)+1,4.)||"01";
													    else month3 = put(year(AdmitDt),4.)||put(month(AdmitDt)+1,z2.);
													    end;
							    else month3 = put(year(AdmitDt),4.)||put(month(AdmitDt),z2.);
							    end;
else if wend - mbeg &amp;lt; 7 then do;
                             if wend - mbeg &amp;lt; 3 then do;
                                                     if month(AdmitDt) = 1 then month3 = put(year(AdmitDt) - 1,4.) || "12";
                                                        else month3 = put(year(AdmitDt),4.)||put(month(AdmitDt)-1,z2.);
													 end;
							 else month3 = put(year(AdmitDt),4.)||put(month(AdmitDt),z2.);
							 end;
  
  mth3 = substr(month3, 5, 2);  
  month33 = put(mth3, $mth.);  
  year3 = substr(month3, 1, 4);  
  

	  /* Additional processing  */  
  length wk2 $8.;  
  format year $4.;  
    

    
  mth2 = put(month(AdmitDt), z2.);  
  year = put(year(AdmitDt), 4.);  
    
  wk1 = compress('wk' || put(week(AdmitDt), z2.));  
  wk2 = compress(substr(year, 3, 2) || '_' || wk1);   
run;  


data _null_;
format dt date9.;
 dt='16JAN2025'D;
 cut_dt=intnx('month','16JAN2025'D,-23);
 CALL symput('currmo', compress(put(year(dt),z4.))||compress(put(month(dt),z2.)));
 CALL symput('cutmo', compress(put(year(cut_dt),z4.))||compress(put(month(cut_dt),z2.)));
 run;

%put &amp;amp;currmo.;
%put &amp;amp;cutmo.;

data _null_;
  td='16JAN2025'D;
  format cutdt date9. cutdt2 date9.;
  cutdt=intnx('month','16JAN2025'D,0); 
  cutdt2=intnx('month','16JAN2025'D,0);
  cutmth=compress(put(year(cutdt), 4.)||put((month(cutdt)), z2.));
  call symput('cutmth', cutmth);
  
run;

%put &amp;amp;cutmth.;

data ip2;  
  set ip;  
  format season_yr $20.;  
  
  /* Determine season year */  
  if '202009' &amp;lt;= month3 &amp;lt;= '202108' then season_yr = "Yr_20_21";  
  else if '202109' &amp;lt;= month3 &amp;lt;= '202208' then season_yr = "Yr_21_22";  
  else if '202209' &amp;lt;= month3 &amp;lt;= '202308' then season_yr = "Yr_22_23";  
  else if '202309' &amp;lt;= month3 &amp;lt;= '202408' then season_yr = "Yr_23_24";  
  else if '202409' &amp;lt;= month3 &amp;lt;= '202508' then season_yr = "Yr_24_25";  
  else season_yr = 'Other';  
  
  /* Standardize weeks  */  
  if year = "2020" then do;  
    wk1 = compress('wk' || put(week(AdmitDt) + 1, z2.));  
    wk2 = compress(substr(year, 3, 2) || '_' || wk1);  
  end;  
  else if year in ("2021", "2022", "2023") then do;  
    wk1 = compress('wk' || put(week(AdmitDt), z2.));  
    wk2 = compress(substr(year, 3, 2) || '_' || wk1);  
  end;  
  else if year = "2024" then do;  
    wk1 = compress('wk' || put(week(AdmitDt) + 1, z2.));  
    wk2 = compress(substr(year, 3, 2) || '_' || wk1);  
  end;  
   else if year = "2025" then do;  
    wk1 = compress('wk' || put(week(AdmitDt), z2.));  
    wk2 = compress(substr(year, 3, 2) || '_' || wk1);  
  end;  
  
  /* Adjust for special cases */  
  if season_yr = "Yr_21_22" and wk1 = "wk35" and year = "2021" then season_yr = "Yr_20_21";  

  if year = "2021" and wk1 = "wk00" then do;  
    wk1 = "wk53";  
    wk2 = "20_wk53";  
    year = "2020";  
    mth2 = "12";  
  end;  
  if year = "2022" and wk1 = "wk00" then do;  
    wk1 = "wk52";  
    wk2 = "21_wk52";  
    year = "2021";  
    mth2 = "12";  
  end;  

  if year = "2020" and wk1 = "wk53" then delete;  

  if year = "2023" and wk1 = "wk53" then do;  
    wk1 = "wk01";  
    wk2 = "24_wk01";  
    year = "2024";  
    mth2 = "01";  
  end;  

/*2025 adjustments - attempted below*/

/* 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; */


  
  month = year || mth2;  
run;  &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any help is appreciated. I've been stuck on this for days. It seems it should be simple but I attempted many ways but it either doubled the counts for one week or just didnt push into the bucket I needed&amp;nbsp; to go into.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 04:06:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956627#M45767</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T04:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956629#M45768</link>
      <description>&lt;P&gt;I can hardly say anything useful to solve your problem without seeing the dataset &lt;FONT face="courier new,courier"&gt;ip&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;Formats exist to show dates as week + year, so the fancy string concatenations seem to be obsolete.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 06:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956629#M45768</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2025-01-20T06:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956671#M45774</link>
      <description>&lt;P&gt;Correction in the total freq numbers for the top table:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Deesee_1-1737388584688.png" style="width: 646px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103854i76B0DAE71331CF88/image-dimensions/646x379?v=v2" width="646" height="379" role="button" title="Deesee_1-1737388584688.png" alt="Deesee_1-1737388584688.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 15:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956671#M45774</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T15:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956677#M45775</link>
      <description>There is a sample of the ip table but do you need more rows from it? It's over 18 million rows. The if then do in the next step is the issue. It looks like the top table but needs to look like the bottom table. I think I'm doing the if then do right but it for some reason doesn't assign properly.</description>
      <pubDate>Mon, 20 Jan 2025 16:16:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956677#M45775</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T16:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956685#M45777</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/468982"&gt;@Deesee&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;There is a sample of the ip table but do you need more rows from it? It's over 18 million rows. The if then do in the next step is the issue. It looks like the top table but needs to look like the bottom table. I think I'm doing the if then do right but it for some reason doesn't assign properly.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;To check behavior of code requires examples of the input data, best as a working data step. Variable types cannot be determined from pictures of tables and code cannot be tested.&lt;/P&gt;
&lt;P&gt;If there are specific values that have "issues" then examples of the data set with those values are helpful.&lt;/P&gt;
&lt;P&gt;Since Proc Freq would generate OUTPUT it does tend to hide what the INPUT might have been not to mention that the code shown will not generate the output shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A clearer description of the problem and desired output would be helpful. I can't highlight or copy/paste&lt;/P&gt;
&lt;P&gt;out the sections to discuss because all you provided was a picture. But there is nothing to say WHY "first row should be 25 wk01 not 24 wk53" without input values that should be assigned the output.&lt;/P&gt;
&lt;P&gt;Or exactly what is a "special case".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that there are 3 specific Formats for SAS date values that assign week values based on some rules involving start of week and end / start of year, WEEKU. WEEKV. WEEKW.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also make custom formats using Proc Format involving the U, V and W rules for start/ end of year. But without a clear description of your "special case" definition can't make specific suggestions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally almost anything involving that much string manipulation of dates is more complicated than working directly with the Proc Format directives for PICTURE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 17:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956685#M45777</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-01-20T17:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956687#M45778</link>
      <description>I'm sorry but all the formatting is in the SAS code posted. There are formats for all the fields in the SAS code. Also the results show what they look like after applying the formats. I thought that would be helpful.</description>
      <pubDate>Mon, 20 Jan 2025 17:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956687#M45778</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T17:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956688#M45779</link>
      <description>&lt;P&gt;Examples and instructions to provide us the data&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_blank"&gt;https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 17:58:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956688#M45779</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-01-20T17:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956690#M45780</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;data ip2;
 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:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956690#M45780</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T19:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956693#M45782</link>
      <description>&lt;P&gt;That data step won't run as written.&amp;nbsp; Not hard to fix the obvious mistakes, like missing semicolon,&amp;nbsp; wrong widths on informats (and hence wrong implied lengths for the variables), missing infile statement, missing format statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Harder to fix having different number of variables read than values on the lines.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you mean something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ip2;
  infile datalines dsd truncover;
  input
    season_yr :$20.
    wbeg :DATE.
    wend :DATE.
    wk1 :$9.
    wk2 :$4.
    year1 :$4.
    year2 :$4.
    month3 :$6. 
    month33 :$3.
  ;
  format wbeg wend date9.;
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
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&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="Screenshot 2025-01-20 at 3.47.58 PM.png" style="width: 790px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103860i13FDF259270DF768/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-20 at 3.47.58 PM.png" alt="Screenshot 2025-01-20 at 3.47.58 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Is that the INPUT or the OUTPUT?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also why does the text in the WK1 variable use lowercase letters but it uses mixed case letters in the WK2 variable?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 21:22:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956693#M45782</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-20T21:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956696#M45783</link>
      <description>&lt;P&gt;This statement in your first PICTURE is problematic.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-01-20 at 3.59.19 PM.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103861iEB86E0DF8472EAB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-01-20 at 3.59.19 PM.png" alt="Screenshot 2025-01-20 at 3.59.19 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You have to have some way to have years with 53 weeks in them since the number of days in a year does not divide evenly into 7 day weeks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you want to handle the extra days?&amp;nbsp; Do you want to have some years with a week 0 instead of the week 53 you are complaining about?&amp;nbsp; Do you want to allow week1 and/or week52 to have more than 7 days?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you spell out the rules you want to use to fix the week assignments?&lt;/P&gt;
&lt;P&gt;What day of the week do weeks start on? Is it Sunday? Or some other day?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What variable has the actual dates?&amp;nbsp; Are those the WBEG and WEND variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 21:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956696#M45783</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-20T21:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956699#M45785</link>
      <description>&lt;P&gt;wbeg and wend have the actual date ranges. Also, the calculation for those are in the posted SAS code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;  wbeg = intnx('week', AdmitDt, 0, 'b');  
  wend = intnx('week', AdmitDt, 0, 'e'); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 21:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956699#M45785</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T21:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956700#M45786</link>
      <description>Yes that is fine. It shouldnt be mixed case it's lower case.</description>
      <pubDate>Mon, 20 Jan 2025 21:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956700#M45786</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T21:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956702#M45788</link>
      <description>Figured it out; just included an else if statement.</description>
      <pubDate>Mon, 20 Jan 2025 22:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956702#M45788</guid>
      <dc:creator>Deesee</dc:creator>
      <dc:date>2025-01-20T22:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: IF THEN DO - Issues</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956703#M45789</link>
      <description>&lt;P&gt;I still do not understand what the question you are asking is.&amp;nbsp; Are you having trouble understanding the code you shared?&amp;nbsp; Is it not doing what you want?&amp;nbsp; You mentioned something about PROC FREQ and then showed results with many more variables than included in the TABLES statement you showed, so it is not clear what the issue is.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you having trouble generating the many different variables from the ADMITDT?&amp;nbsp; Which ones are giving you trouble.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which of those variaables do you actually NEED?&amp;nbsp; For example many of them can easily be regenerated from one or more of the others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to fix your current code I would start by simplifying it.&amp;nbsp; For example if you want to generate YYYYMM strings from a DATE value just use the YYMMN6. format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month3 = put(admitdt,yymmn6.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want to adjust a date by a month use in the INTNX() function.&amp;nbsp; For example to get the next or previous month use 1 or -1 as the offset value in the call.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;month3 = put(intnx('month',admitdt,1),yymmn6.);
month3 = put(intnx('month',admitdt,-1),yymmn6.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Jan 2025 22:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/IF-THEN-DO-Issues/m-p/956703#M45789</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-01-20T22:26:38Z</dc:date>
    </item>
  </channel>
</rss>

