<?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: problem with Date informat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470154#M120347</link>
    <description>&lt;P&gt;i have never used parentheses in that way, and never had a problem, but the book would certainly be right, i may be out of touch&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jun 2018 00:11:03 GMT</pubDate>
    <dc:creator>pau13rown</dc:creator>
    <dc:date>2018-06-14T00:11:03Z</dc:date>
    <item>
      <title>problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470147#M120343</link>
      <description>&lt;P&gt;Dear friends, this is my first step to SAS world and while following the examples of "The little SAS Book",&lt;/P&gt;&lt;P&gt;I am suffering from using date informat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have uploaded the data, which is pumpkin2.txt and here's my code I typed in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA contest;
	infile '/folders/myfolders/sasuser.v94/pumpkin3.txt';
	input Name $16. Age 3. +1 Type $1. +1 DATE MMDDYYYY10. (Score1 Score2 Score3 Score4 Score5) 4.1;
RUN;

PROC PRINT DATA = contest;
RUN;
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is what my SAS studio says:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;DIV class="sasSource"&gt;1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;72&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;73 DATA contest;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;74 infile '/folders/myfolders/sasuser.v94/pumpkin2.txt';&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;75 input Name $16. Age 3. +1 Type $1. +1 DATE MMDDYYYY10. (Score1 Score2 Score3 Score4 Score5) 4.1;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;___________ ___&lt;/DIV&gt;&lt;DIV class="sasError"&gt;485 79&lt;/DIV&gt;&lt;DIV class="sasError"&gt;76&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE 485-185: Informat MMDDYYYY was not found or could not be loaded.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 79-322: Expecting a (.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;76 RUN;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/DIV&gt;&lt;DIV class="sasWarning"&gt;WARNING: The data set WORK.CONTEST may be incomplete. When this step was stopped there were 0 observations and 4 variables.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: DATA statement used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.01 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;77&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;78 PROC PRINT DATA = contest;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;79 RUN;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: No observations in data set WORK.CONTEST.&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;NOTE: PROCEDURE PRINT used (Total process time):&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;real time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;cpu time 0.00 seconds&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasNote"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;80&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;81&lt;/DIV&gt;&lt;DIV class="sasSource"&gt;82 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;PRE class="sasLog"&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;Please help. P.S: for some of rows in the data, the Name field, are less than 16 characters and in the source code I have defined it as long as 16 characters. Is this the reason?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 23:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470147#M120343</guid>
      <dc:creator>jimmychoi</dc:creator>
      <dc:date>2018-06-13T23:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470149#M120344</link>
      <description>&lt;P&gt;i'm not sure about the parentheses around score variables. Maybe just "score1-score5 4.1". For the date variable try format "date9." or "date10."&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2018 23:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470149#M120344</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-13T23:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470150#M120345</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE 485-185: Informat MMDDYYYY was not found or could not be loaded.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Seems like a reasonably clear error message to me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You probably meant to ask for the MMDDYY informat instead.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 00:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470150#M120345</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-14T00:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470151#M120346</link>
      <description>For the score variables and their brackets, I wrote as what it's written in the book. Does that mean the syntax could have been changed?</description>
      <pubDate>Thu, 14 Jun 2018 00:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470151#M120346</guid>
      <dc:creator>jimmychoi</dc:creator>
      <dc:date>2018-06-14T00:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470154#M120347</link>
      <description>&lt;P&gt;i have never used parentheses in that way, and never had a problem, but the book would certainly be right, i may be out of touch&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 00:11:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470154#M120347</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-14T00:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470155#M120348</link>
      <description>Hi Tom, apologize if I have caused a confusion with the wordings. Should it be differentiated? Date informat vs MMDDYY informat&lt;BR /&gt;&lt;BR /&gt;P.S original data is written in MM-DD-YYYY format (e.g. 10-31-2013)</description>
      <pubDate>Thu, 14 Jun 2018 00:12:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470155#M120348</guid>
      <dc:creator>jimmychoi</dc:creator>
      <dc:date>2018-06-14T00:12:06Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470156#M120349</link>
      <description>&lt;P&gt;no, i would replace the mmddyy format with date9.; ive had problems with ddmmyyyy type formats before and thus i always use date9. Give it a try and see if it works&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 00:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470156#M120349</guid>
      <dc:creator>pau13rown</dc:creator>
      <dc:date>2018-06-14T00:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: problem with Date informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470157#M120350</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/215463"&gt;@jimmychoi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Tom, apologize if I have caused a confusion with the wordings. Should it be differentiated? Date informat vs MMDDYY informat&lt;BR /&gt;&lt;BR /&gt;P.S original data is written in MM-DD-YYYY format (e.g. 10-31-2013)&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If the data is in the form 10-31-2013 then you definitely want the MMDDYY informat. Since you are using fixed format input you need to set the width to match the number of columns that are reserved in the input line for that field.&amp;nbsp; 8 digits and two hyphens means you want width of 10.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But it looks like your sample data file is not in fixed columns.&lt;/P&gt;
&lt;PRE&gt;Alicia Grossman 13 C 10-28-2012 7.8 6.5 7.2 8.0 7.9
Matthew Lee 9 D 10-30-2012 6.5 5.9 6.8 6.0 8.1
Elizabeth Garcia 10 C 10-29-2012 8.9 7.9 8.5 9.0 8.8
Lori Newcombe 6 D 10-30-2012 6.7 5.6 4.9 5.2 6.1
Jose Martinez 7 d 10-31-2012 8.9 9.5 10.0 9.7 9.0
Brian Williams 11 C 10-29-2012 7.8 8.4 8.5 7.9 8.0&lt;/PRE&gt;
&lt;P&gt;So you cannot use a formatted input statement to read those lines.&amp;nbsp; For example the date does not appear in the same place on every line.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to use list mode input instead.&amp;nbsp; Since you don't need to use formats in the input statement it will be easier if you define the variables BEFORE using them in the INPUT statement.&amp;nbsp; Since SAS knows how to read numbers and character strings you only need to specify a informat for the date.&amp;nbsp; And since you are using list mode you don't need to specify the width of the informat since SAS will ignore it any way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also since your data is not in fixed columns and you don't have an extra space after the NAME field you will need to read the name as two variables.&amp;nbsp; If any of the rows have middle names or initials then you will have problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA contest;
  infile '/folders/myfolders/sasuser.v94/pumpkin2.txt';
  length Fname Lname $16 Age 8 Type $1 DATE 8 Score1-Score5  8 ;
  informat Date mmddyy. ;
  format date yymmdd10.;
  input Fname -- Score5 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also do NOT add a decimal part to an informat unless you know that the decimal point was purposely NOT included in the text of the source file.&amp;nbsp; When you add a decimal part to an informat you are telling SAS where the implied decimal point is So if any of your score values were wrtten into the text file WITHOUT a period, for example integer values, then the result of reading it with 4.1 informat would be to divide the value by 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jun 2018 00:34:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/problem-with-Date-informat/m-p/470157#M120350</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-06-14T00:34:08Z</dc:date>
    </item>
  </channel>
</rss>

