<?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: Convert month format to character in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587078#M167622</link>
    <description>&lt;P&gt;gap_months is, per definition from the previous step, numeric, so the conversion with the input() function is not necessary.&lt;/P&gt;
&lt;P&gt;From your code I infer that birthdate and admdate are SAS dates, and to calculate the month difference between dates, one uses the intck() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;gap_months = intck('month',birthdate,admdate,'c');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;gap_monthschar = put(gap_months,z2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;both can be done in one step.&lt;/P&gt;</description>
    <pubDate>Sun, 08 Sep 2019 15:18:54 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-09-08T15:18:54Z</dc:date>
    <item>
      <title>Convert month format to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587073#M167619</link>
      <description>&lt;P&gt;Hello. I am trying to convert a numeric date variable into a character. Code below. Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*previous step;
data have1; set have;
gap_months=birthdate-admdate;
format gap_months month.;
run;

*This provided me with the difference in months from the birth hospital visit to
the hospital readmission . Now I want to turn the variable gap_months into a character;


I tried the following, it didn't work - any suggestions? thank you;

data want; set have1;
 gap_monthschar=  put(input( gap_months,best.),z2.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 08 Sep 2019 13:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587073#M167619</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-09-08T13:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month format to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587074#M167620</link>
      <description>&lt;P&gt;More than the code, a sample data of what you 'have' and what you 'want' will help many understand better plz&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 14:17:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587074#M167620</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-09-08T14:17:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month format to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587077#M167621</link>
      <description>&lt;P&gt;Yes, sorry about that. I figured it the syntax in the meantime. I was looking for the function month(). This helped me get the month of both dates in a format that I wanted. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; Thank you for your reply.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 14:36:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587077#M167621</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-09-08T14:36:29Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month format to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587078#M167622</link>
      <description>&lt;P&gt;gap_months is, per definition from the previous step, numeric, so the conversion with the input() function is not necessary.&lt;/P&gt;
&lt;P&gt;From your code I infer that birthdate and admdate are SAS dates, and to calculate the month difference between dates, one uses the intck() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;gap_months = intck('month',birthdate,admdate,'c');&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;gap_monthschar = put(gap_months,z2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;both can be done in one step.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 15:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587078#M167622</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-08T15:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert month format to character</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587082#M167626</link>
      <description>&lt;P&gt;Great&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; . That solution worked, thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 08 Sep 2019 16:03:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-month-format-to-character/m-p/587082#M167626</guid>
      <dc:creator>eabc0351</dc:creator>
      <dc:date>2019-09-08T16:03:15Z</dc:date>
    </item>
  </channel>
</rss>

