<?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: Character $ 15. to date conversion in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526580#M143435</link>
    <description>&lt;P&gt;are you asking for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
do _n_=1992 to year(today());
charyear=put(_n_,15. -l);
output;
end;
run;

data want;
set have;
numyear=input(charyear,best32.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure what you mean by&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;convert this to date(only year)&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Jan 2019 06:27:49 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-01-12T06:27:49Z</dc:date>
    <item>
      <title>Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526579#M143434</link>
      <description>&lt;P&gt;Hi dear members,&lt;/P&gt;&lt;P&gt;I have a column variable for the year of inspection since 1992 up to now stored as char $ 15.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1992&lt;/P&gt;&lt;P&gt;1993&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;2017&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;I would be grateful if anyone could help me to convert this to date(only year) and use it as variable for x-axis.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 06:15:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526579#M143434</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2019-01-12T06:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526580#M143435</link>
      <description>&lt;P&gt;are you asking for this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
do _n_=1992 to year(today());
charyear=put(_n_,15. -l);
output;
end;
run;

data want;
set have;
numyear=input(charyear,best32.);
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Not sure what you mean by&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;convert this to date(only year)&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 06:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526580#M143435</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-01-12T06:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526589#M143440</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;thank you for your reply.&lt;/P&gt;&lt;P&gt;The inspection year variable contains only the year and is stored as Char $15. . I want to change its type to date type. If I use the date type as a variable it shall be considered as date not char of numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;your code changed the char to numeric which is not the type I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 13:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526589#M143440</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2019-01-12T13:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526595#M143445</link>
      <description>&lt;P&gt;Then you have a problem.&amp;nbsp; There is no such thing as a date type in SAS.&amp;nbsp; The only types of variables are character and numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does support calculations with dates, but those are numeric calculations.&amp;nbsp; Dates are just another instance of a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Technically, dates in SAS refer to a specific day.&amp;nbsp; It is not possible to have a date refer to an entire year.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The suggestion that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;gave you should be sufficient for using the year as an axis on a plot.&amp;nbsp; If you try it an run into problems, post the log from your program.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 15:06:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526595#M143445</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2019-01-12T15:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526602#M143450</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/253384"&gt;@mmhxc5&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need a &lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=p07m2vpyq75fgan14m6g5pphnwlr.htm&amp;amp;locale=en#n06779imap6mdfn1nx7oe8j6nklv" target="_blank"&gt;time axis&lt;/A&gt;, you should create SAS date values, e.g., for 1 January of the year of inspection:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
date=input(cats(charyear,'Q1'),yyq6.);
format date year.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(using novinosrin's dataset HAVE).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then use DATE as the x variable, for example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=want;
series x=date y=date; /* replace y=date with something more interesting */
xaxis interval=year minor minorinterval=quarter label='Year of inspection';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Jan 2019 15:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526602#M143450</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-01-12T15:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526636#M143470</link>
      <description>&lt;P&gt;Create a new variable using the MDY() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;INPUT() will convert it to a number first, avoiding notes in the log.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;new_date = mdy(1, 1, input(year, 8.));
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 12 Jan 2019 19:15:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526636#M143470</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-12T19:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Character $ 15. to date conversion</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526666#M143477</link>
      <description>&lt;P&gt;Thank you everyone for your time and help!&lt;/P&gt;&lt;P&gt;Appreciated!&lt;/P&gt;</description>
      <pubDate>Sat, 12 Jan 2019 22:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Character-15-to-date-conversion/m-p/526666#M143477</guid>
      <dc:creator>mmhxc5</dc:creator>
      <dc:date>2019-01-12T22:38:07Z</dc:date>
    </item>
  </channel>
</rss>

