<?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: How to specify a particular month when creating a date variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/539528#M7075</link>
    <description>Yes it did! Thank you!</description>
    <pubDate>Fri, 01 Mar 2019 01:01:17 GMT</pubDate>
    <dc:creator>cheenaChuks</dc:creator>
    <dc:date>2019-03-01T01:01:17Z</dc:date>
    <item>
      <title>How to specify a particular month when creating a date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538177#M6897</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am totally new to sas&amp;nbsp;and I am trying to find a way to specify a particular month when creating my date variable. I have included the problem question in the comment of my code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Question 4: Using the Hosp SAS dataset, create a new temporary SAS dataset which contains only patients born after August 05, 1950. Extract the day from the birth date (DOB) and the year from the admission date (AdmitDate). Create a new date variable named DateNew using these 2 variables and the month of May.Calculate each patient's age as of January 27, 2018. And using a date interval function with the ‘sameday’ option, identify a scheduled return visit date that is 5 months after the discharge date. Format all dates as YYYY-MM-DD and print observations for patients who have IDs between 15 and 45 inclusive.*/;
libname cb "I:\My Documents\552\codybook"; 
data thosp;
		set cb.hosp (where = (DOB gt '05Aug1950'd));
		/*Extracting day and year from DOB and AdmitDate Respectively*/
		dy = day(DOB); 
		yr = year(AdmitDate); 
		mnth = mnth(‘May’);
		DateNew = mdy(mnth,dy,yr);
		Age = yrdif(DOB,'27Jan2018'd);
		ReturnVisitDate =intnx('month', DischrDate, 5, 'sameday');
		format DOB yymmdd10. ReturnVisit yymmdd10. AdmitDate yymmdd10. DateNew yymmdd10. DischrDate yymmdd10.;
run;
proc contents data = thosp;
run;
proc print data = thosp (obs=2);
run;
proc print data = thosp;
where ID in (15:45);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Please see the attached screenshot error I keep getting and my code below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 04:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538177#M6897</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-02-25T04:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify a particular month when creating a date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538178#M6898</link>
      <description>&lt;P&gt;Welcome to the Forum!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The error message says it: there is no function named mnth. There is no need for such a function.... you can just write mnth = 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The other message is caused by a missing semicolon, an error that's already fixed in your posted code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 04:21:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538178#M6898</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-02-25T04:21:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify a particular month when creating a date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538189#M6903</link>
      <description>&lt;P&gt;Fixed Code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname cb "I:\My Documents\552\codybook"; 
data thosp;
		set cb.hosp (where = (DOB gt '05Aug1950'd));
		/*Extracting day and year from DOB and AdmitDate Respectively*/
		dy = day(DOB); 
		yr = year(AdmitDate); 
		mnth = 5;/*May*/
		DateNew = mdy(mnth,dy,yr);
		Age = yrdif(DOB,'27Jan2018'd);
		ReturnVisitDate =intnx('month', DischrDate, 5, 'sameday');
		format DOB yymmdd10. ReturnVisit yymmdd10. AdmitDate yymmdd10. DateNew yymmdd10. DischrDate yymmdd10.;
run;
proc contents data = thosp;
run;
proc print data = thosp (obs=2);
run;
proc print data = thosp;
where ID in (15:45);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;SAS Month function&amp;nbsp;&lt;SPAN&gt;Returns the month from a SAS date value, it does not convert May to 5.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please let us know if it worked for you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Feb 2019 05:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/538189#M6903</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2019-02-25T05:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify a particular month when creating a date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/539528#M7075</link>
      <description>Yes it did! Thank you!</description>
      <pubDate>Fri, 01 Mar 2019 01:01:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/539528#M7075</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-03-01T01:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify a particular month when creating a date variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/539529#M7076</link>
      <description>&lt;P&gt;Yes I realized that too! Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 01:02:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-specify-a-particular-month-when-creating-a-date-variable/m-p/539529#M7076</guid>
      <dc:creator>cheenaChuks</dc:creator>
      <dc:date>2019-03-01T01:02:49Z</dc:date>
    </item>
  </channel>
</rss>

