<?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 Input Function - Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230406#M41776</link>
    <description>&lt;PRE&gt;data TEST;
	set DATASET;
	monthIn = scan(Date,1);
	month = input(monthIn,4.);
	day = input(scan(Date,2),4.);
	year = input(scan(Date,3),4.);
run;&lt;/PRE&gt;&lt;P&gt;I have dates like&amp;nbsp;&lt;SPAN&gt; Date=9/1/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and my code returns&amp;nbsp;&lt;SPAN&gt;monthIn=9 month=. day=1 year=2012.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why does month not return month=9?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 17 Oct 2015 12:51:31 GMT</pubDate>
    <dc:creator>cody</dc:creator>
    <dc:date>2015-10-17T12:51:31Z</dc:date>
    <item>
      <title>Input Function - Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230406#M41776</link>
      <description>&lt;PRE&gt;data TEST;
	set DATASET;
	monthIn = scan(Date,1);
	month = input(monthIn,4.);
	day = input(scan(Date,2),4.);
	year = input(scan(Date,3),4.);
run;&lt;/PRE&gt;&lt;P&gt;I have dates like&amp;nbsp;&lt;SPAN&gt; Date=9/1/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and my code returns&amp;nbsp;&lt;SPAN&gt;monthIn=9 month=. day=1 year=2012.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Why does month not return month=9?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 12:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230406#M41776</guid>
      <dc:creator>cody</dc:creator>
      <dc:date>2015-10-17T12:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Input Function - Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230408#M41778</link>
      <description>&lt;P&gt;Try this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TEST;&lt;BR /&gt;input date $;&lt;BR /&gt; monthIn = scan(Date,1);&lt;BR /&gt; month = input(monthIn,4.);&lt;BR /&gt; day = input(scan(Date,2),4.);&lt;BR /&gt; year = input(scan(Date,3),4.);&lt;BR /&gt;datalines;&lt;BR /&gt;9/1/2012&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc print data=test;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 14:39:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230408#M41778</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2015-10-17T14:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Input Function - Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230440#M41786</link>
      <description>&lt;P&gt;It's normally better to convert a string representing a date into an actual SAS date value. Once you've got a SAS date value you can format however you want to with either OOTB formats or your own picture format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  picture mdy_nums
    low-high ='month=%m Day=%d Year=%Y' (datatype=date)
    ;
quit;
 

data TEST;
  input date $;
  sas_date=input(date,mmddyy10.);
  format sas_date mdy_nums.;

  month=month(sas_date);
  day=day(sas_date);
  year=year(sas_date);

  datalines;
9/1/2012
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/539iDA3725FB1669B2F2/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Oct 2015 22:06:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Input-Function-Error/m-p/230440#M41786</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-10-17T22:06:21Z</dc:date>
    </item>
  </channel>
</rss>

