<?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: Date change in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727844#M28236</link>
    <description>&lt;P&gt;Update: Once I removed the 3 typed in dates it worked for my dataset. Thank you very much for the help!&lt;/P&gt;</description>
    <pubDate>Fri, 19 Mar 2021 18:36:12 GMT</pubDate>
    <dc:creator>nmlynar13</dc:creator>
    <dc:date>2021-03-19T18:36:12Z</dc:date>
    <item>
      <title>Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727821#M28226</link>
      <description>&lt;P&gt;I have a column full of dates in the following format "04JAN2010" and would like to have it reformatted to just so the year ("2010"). I saw on a previous post about using the length function, however I got an error because its a "numeric variable"&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 17:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727821#M28226</guid>
      <dc:creator>nmlynar13</dc:creator>
      <dc:date>2021-03-19T17:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727833#M28229</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366638"&gt;@nmlynar13&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does the following code give you what you want?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FYI, SAS dates are stored as numerics and can be formatted to be more human readable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create input data */
data have;
   format my_date date9.;

   input my_date date9.;

   datalines;
19mar2020
19mar2021
19mar2022
;


/* format a new column to just show the year */
data want;
   set have;

   format my_date2 year.;

   my_date2 = my_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 17:55:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727833#M28229</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-03-19T17:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727839#M28233</link>
      <description>&lt;P&gt;Hi Amir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the response, this code does run without errors, however it deletes all data observations and produced just&amp;nbsp;two columns (original date and new date) without any data in it.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data easy;
	format announcement_date date9.;
	input announcement_date date9.;
	datalines;
	19mar2020
	19mar2021
	19mar2022
	;
	
data easy2;
	set easy;
	format date2 year.;
	date2 = announcement_date;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I used the same code you stated with my dataset names and column names.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727839#M28233</guid>
      <dc:creator>nmlynar13</dc:creator>
      <dc:date>2021-03-19T18:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727840#M28234</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366638"&gt;@nmlynar13&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I've understood you correctly, the code you posted needs to be changed to remove the white space before the lines of data. so that it looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data easy;
	format announcement_date date9.;
	input announcement_date date9.;
	datalines;
19mar2020
19mar2021
19mar2022
	;
	
data easy2;
	set easy;
	format date2 year.;
	date2 = announcement_date;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727840#M28234</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-03-19T18:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727842#M28235</link>
      <description>Hi Amir,&lt;BR /&gt;Yes that did output the year when I removed the white space. The only thing is that it output just the 3 dates typed in (19MAR2020, 19MAR2021, 19MAR2022). Is there a way to have to read the dates in the column "announcement_dates" to produce the new column of those years?&lt;BR /&gt;&lt;BR /&gt;Thank you,&lt;BR /&gt;Nick</description>
      <pubDate>Fri, 19 Mar 2021 18:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727842#M28235</guid>
      <dc:creator>nmlynar13</dc:creator>
      <dc:date>2021-03-19T18:29:28Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727844#M28236</link>
      <description>&lt;P&gt;Update: Once I removed the 3 typed in dates it worked for my dataset. Thank you very much for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:36:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727844#M28236</guid>
      <dc:creator>nmlynar13</dc:creator>
      <dc:date>2021-03-19T18:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date change</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727845#M28237</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/366638"&gt;@nmlynar13&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I've understood you correctly, you have an existing data set (I'll call it "have") and you want a new data set (I'll call it "want") with a new column showing the year.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try the below code and substitute your data set names to the ones you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* produce new data set "want" based on existing data set "have" */
data want;
   set have;

   format announcement_dates2 year.;

   announcement_dates2 = announcement_dates;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Amir.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Mar 2021 18:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Date-change/m-p/727845#M28237</guid>
      <dc:creator>Amir</dc:creator>
      <dc:date>2021-03-19T18:40:36Z</dc:date>
    </item>
  </channel>
</rss>

