<?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: Switching between dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547919#M151883</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244700"&gt;@ecam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;First of u believe the formats are&lt;BR /&gt;&lt;BR /&gt;Yymmddn8&lt;BR /&gt;Yymmddn6&lt;BR /&gt;&lt;BR /&gt;But I can’t get them to behave when I try to convert them between formats&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If we try to interpret the '201802' value in your original post as representing a date displayed using the YYMMDDN6 format then that would mean that day of month as 2, month of year as 18 and year in century as 20.&amp;nbsp; Since there are only 12 months in a year that is impossible.&amp;nbsp; More likely that string should be interpreted as meaning the second month in the year 2018.&amp;nbsp; The day of the month is unknown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2019 15:06:20 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-04-02T15:06:20Z</dc:date>
    <item>
      <title>Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547845#M151860</link>
      <description>I have a couple. sets of dates&lt;BR /&gt;201802&lt;BR /&gt;20180201&lt;BR /&gt;&lt;BR /&gt;They both read as numeric.&lt;BR /&gt;Now I need to be able to flip between the two formats&lt;BR /&gt;&lt;BR /&gt;I’ve read about combining input() and put to flip. But it’s already numeric. So not sure how this works.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for the assist</description>
      <pubDate>Tue, 02 Apr 2019 10:26:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547845#M151860</guid>
      <dc:creator>ecam</dc:creator>
      <dc:date>2019-04-02T10:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547846#M151861</link>
      <description>First of u believe the formats are&lt;BR /&gt;&lt;BR /&gt;Yymmddn8&lt;BR /&gt;Yymmddn6&lt;BR /&gt;&lt;BR /&gt;But I can’t get them to behave when I try to convert them between formats</description>
      <pubDate>Tue, 02 Apr 2019 10:27:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547846#M151861</guid>
      <dc:creator>ecam</dc:creator>
      <dc:date>2019-04-02T10:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547853#M151862</link>
      <description>&lt;P&gt;Show us the as-is state by posting example data in usable form (data step with datalines).&lt;/P&gt;
&lt;P&gt;Then show what you want to get as end result from that. Is it a new dataset, or a report? Note that you can only have one format per column throughout a dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 11:20:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547853#M151862</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-02T11:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547860#M151866</link>
      <description>The information I Have was in my first post&lt;BR /&gt;&lt;BR /&gt;The dates are coming in as numeric as follows.&lt;BR /&gt;201802.&lt;BR /&gt;20180201&lt;BR /&gt;&lt;BR /&gt;Because the macro files are so old I don’t want to reinvent the wheel. So depending on the dataset and task. I would be staring at two dataset with the two different date formats that I need to combine.&lt;BR /&gt;&lt;BR /&gt;When I try to use input () and put () to convert I get crazy numbers and if I try to reformat using yymmdd10. I get 02/01/2018 for the last example and garbage for the 201802.&lt;BR /&gt;&lt;BR /&gt;I need to be able to convert either format into the other since I get change the code to standardize.&lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;My goal is a new dataset with one format ideally the 20180201 format</description>
      <pubDate>Tue, 02 Apr 2019 11:39:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547860#M151866</guid>
      <dc:creator>ecam</dc:creator>
      <dc:date>2019-04-02T11:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547865#M151868</link>
      <description>&lt;P&gt;I CAN read, and what you gave me to read was not enough to understand and solve the issue. That should be very obvious from my answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;POST.EXAMPLE.DATA.IN.DATASTEPS.WITH.DATALINES. That allows to recreate the dataset AS IT REALLY IS. No ambiguities about content and attributes like types, formats, lengths.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help us to help you, it is NOT rocket science.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 12:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547865#M151868</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-04-02T12:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547875#M151869</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244700"&gt;@ecam&lt;/a&gt;&amp;nbsp; ,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp; , I and most others need&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what you&lt;/P&gt;
&lt;P&gt;1. HAVE (sample input)&lt;/P&gt;
&lt;P&gt;2. What you WANT( sample output for your input i.e expected)&lt;/P&gt;
&lt;P&gt;3. A brief explanation of the business/convert logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All above in simple terms. We request you to post the above in the easiest description/language possible that is perhaps comprehensive to even non native English speakers like me.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you &amp;amp; Have a nice day!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 12:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547875#M151869</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-04-02T12:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547882#M151873</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244700"&gt;@ecam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I have a couple. sets of dates&lt;BR /&gt;201802&lt;BR /&gt;20180201&lt;BR /&gt;&lt;BR /&gt;They both read as numeric.&lt;BR /&gt;Now I need to be able to flip between the two formats&lt;BR /&gt;&lt;BR /&gt;I’ve read about combining input() and put to flip. But it’s already numeric. So not sure how this works.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance for the assist&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How do you have these sets?&amp;nbsp; Are they in actual SAS datasets?&amp;nbsp; &amp;nbsp; Are they in text files? Post examples of each type of "set of dates".&lt;/P&gt;
&lt;P&gt;When you say "read as numeric" what does that mean? Do you mean that when the original raw text was input as the numbers 201,802 and 20,180,201?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You later mention macro.&amp;nbsp; Does this mean you have macro variables with these values in them?&amp;nbsp; Note that macro variables always contain text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What dates do you want those two strings of digits represent?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume you have a macro variable named DATE that can have either 6 digits or 8 digits and you want to interpret them as YYYYMM or YYYYMMDD form and create an actual date.&amp;nbsp; In that case you just need to append 01 and read the first 8 digits.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date1=201802;
%let date2=%sysfunc(inputn(&amp;amp;date1.01,yymmdd8));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Similarly in a data step&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;date1=201802;
date2=input(cats(date1,'01'),yymmdd8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When DATE1 is already 8 digits long the extra 01 that is appended will be ignored.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 13:01:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547882#M151873</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-02T13:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547910#M151880</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244700"&gt;@ecam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;The information I Have was in my first post&lt;BR /&gt;&lt;BR /&gt;The dates are coming in as numeric as follows.&lt;BR /&gt;201802.&lt;BR /&gt;20180201&lt;BR /&gt;&lt;BR /&gt;Because the macro files are so old I don’t want to reinvent the wheel. So depending on the dataset and task. I would be staring at two dataset with the two different date formats that I need to combine.&lt;BR /&gt;&lt;BR /&gt;When I try to use input () and put () to convert I get crazy numbers and if I try to reformat using yymmdd10. I get 02/01/2018 for the last example and garbage for the 201802.&lt;BR /&gt;&lt;BR /&gt;I need to be able to convert either format into the other since I get change the code to standardize.&lt;BR /&gt;&lt;BR /&gt;I hope this helps.&lt;BR /&gt;&lt;BR /&gt;My goal is a new dataset with one format ideally the 20180201 format&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are these "dates" in a data set? If so run Proc Contents on the data set and show us result. I strongly suspect that you do not have date values but simple numeric values that are attempting to treat as dates. The Proc contents will tell us exactly what sort of data you are dealing with.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FORMATS have no affect on the &lt;STRONG&gt;ability&lt;/STRONG&gt; to combine data sets. Example:&lt;/P&gt;
&lt;PRE&gt;data work.data1;
   x='01JAN2019'd;
   format x date9.;
run;

data work.data2;
   x='02JAN2019'd;
   format x mmddyy10.;
run;

data work.combined;
   set work.data1
       work.data2
   ;
run;&lt;/PRE&gt;
&lt;P&gt;However the first data set containing a common variable&amp;nbsp;when using SET or&amp;nbsp;MERGE&amp;nbsp;will determine the default format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And without the code you actually use to do the input or conversion &lt;STRONG&gt;plus&lt;/STRONG&gt; the actual inputs it is impossible to diagnose what might cause the "garbage". One suspects use of the incorrect informat&amp;nbsp;and possibly an incorrect put to get the string for the informat to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also a FORMAT is a variable property. Within a data set, a variable only can have one format. If you want to see different values then would need to create a character variable applying the appropriate format as desired.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 14:29:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547910#M151880</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-04-02T14:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Switching between dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547919#M151883</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/244700"&gt;@ecam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;First of u believe the formats are&lt;BR /&gt;&lt;BR /&gt;Yymmddn8&lt;BR /&gt;Yymmddn6&lt;BR /&gt;&lt;BR /&gt;But I can’t get them to behave when I try to convert them between formats&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If we try to interpret the '201802' value in your original post as representing a date displayed using the YYMMDDN6 format then that would mean that day of month as 2, month of year as 18 and year in century as 20.&amp;nbsp; Since there are only 12 months in a year that is impossible.&amp;nbsp; More likely that string should be interpreted as meaning the second month in the year 2018.&amp;nbsp; The day of the month is unknown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2019 15:06:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Switching-between-dates/m-p/547919#M151883</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-02T15:06:20Z</dc:date>
    </item>
  </channel>
</rss>

