<?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: Converting three types of date information in numeric form to one date form? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603365#M16934</link>
    <description>&lt;P&gt;Please provide your interpretation of what those strings of digits mean.&lt;/P&gt;
&lt;P&gt;The first one might by MMYY ?&amp;nbsp; Are any of them in the form MYY (meaning January thru September)?&lt;/P&gt;
&lt;P&gt;Looks like 2 is in YYYYMMDD order.&lt;/P&gt;
&lt;P&gt;And perhaps 3 is in YYYYMM order?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to set the ones without day of the month to the first day of the month?&amp;nbsp; Also for the second one where you DO have a day of the month do you want to also convert it to the first day of month?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  select (length(cats(FAKE_DATE)));
    when (3,4) REAL_DATE=input('01'||put(FAKE_DATE,z4.),ddmmyy6.);
    when (8) REAL_DATE=intnx('month',input(put(FAKE_DATE,z8.),yymmdd8.),0,'b');
    when (6) REAL_DATE=input(put(FAKE_DATE,z6.),yymmn6.);
    otherwise do;
       put 'WARNING: Invalid DATE value. ' FAKE_DATE= ;
    end;
  end;
  format REAL_DATE yymm7. ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 11 Nov 2019 21:36:07 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-11-11T21:36:07Z</dc:date>
    <item>
      <title>Converting three types of date information in numeric form to one date form?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603350#M16930</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working with three different data sets that have date information currently stored in "numeric" form. I would like to convert the date information in all three of these data sets to a SAS-recognized "date" form, both for conformity among data sets and ease of analysis.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example of the three numeric date formats among the data sets:&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="Example.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/33845iA94C1F87BAFFF840/image-size/small?v=v2&amp;amp;px=200" role="button" title="Example.png" alt="Example.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My biggest challenge is working with the date format for Dataset 1 in the example. I have tried using input/put functions suggested in other areas of this forum to convert this numeric-type variable to date-type, but SAS seems to be having trouble recognizing this as MMYY format, without DD information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My overall goal is to have all three data sets have date information in MM/YYYY format.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if I can provide any more details, and thank you so much for your assistance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Diana&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 20:46:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603350#M16930</guid>
      <dc:creator>disosa</dc:creator>
      <dc:date>2019-11-11T20:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting three types of date information in numeric form to one date form?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603351#M16931</link>
      <description>Use LENGTHN() to get the length or convert it to a character to find the length and then conditionally process each type based on the length. What would you expect as results from #1 and #3?</description>
      <pubDate>Mon, 11 Nov 2019 20:51:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603351#M16931</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-11T20:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Converting three types of date information in numeric form to one date form?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603352#M16932</link>
      <description>&lt;P&gt;Here are instructions on how to provide sample data as a data step:&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 20:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603352#M16932</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-11T20:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting three types of date information in numeric form to one date form?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603365#M16934</link>
      <description>&lt;P&gt;Please provide your interpretation of what those strings of digits mean.&lt;/P&gt;
&lt;P&gt;The first one might by MMYY ?&amp;nbsp; Are any of them in the form MYY (meaning January thru September)?&lt;/P&gt;
&lt;P&gt;Looks like 2 is in YYYYMMDD order.&lt;/P&gt;
&lt;P&gt;And perhaps 3 is in YYYYMM order?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to set the ones without day of the month to the first day of the month?&amp;nbsp; Also for the second one where you DO have a day of the month do you want to also convert it to the first day of month?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have ;
  select (length(cats(FAKE_DATE)));
    when (3,4) REAL_DATE=input('01'||put(FAKE_DATE,z4.),ddmmyy6.);
    when (8) REAL_DATE=intnx('month',input(put(FAKE_DATE,z8.),yymmdd8.),0,'b');
    when (6) REAL_DATE=input(put(FAKE_DATE,z6.),yymmn6.);
    otherwise do;
       put 'WARNING: Invalid DATE value. ' FAKE_DATE= ;
    end;
  end;
  format REAL_DATE yymm7. ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Nov 2019 21:36:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603365#M16934</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-11-11T21:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Converting three types of date information in numeric form to one date form?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603366#M16935</link>
      <description>&lt;P&gt;I understand you have several datasets but here's how I'd handle it in each case (assuming the first of the month when there is no day):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input dataset $ date;
	datalines;
01 1119
02 20191111
03 201911
;
run;

data want;
	set have;
	format date_new date9.;
	date_str = put(left(date),$8.);

	if dataset='01' then date_new=input("01"||date_str,ddmmyy8.);

	if dataset='02' then date_new=input(date_str,yymmdd10.);

	if dataset='03' then date_new=input(date_str,yymmn6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-unison&lt;/P&gt;</description>
      <pubDate>Mon, 11 Nov 2019 21:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Converting-three-types-of-date-information-in-numeric-form-to/m-p/603366#M16935</guid>
      <dc:creator>unison</dc:creator>
      <dc:date>2019-11-11T21:46:03Z</dc:date>
    </item>
  </channel>
</rss>

