<?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 Informat in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736711#M229558</link>
    <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have the coes as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LibName MyLibName 'Path';&lt;BR /&gt;Infile "Path";&lt;BR /&gt;Input Id$ sex$ DOB pdX Dx_3 Dx_4;&lt;BR /&gt;Informat DOB Date9.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know SAS sees the date as number of days away far from January 1st, 1960.&lt;/P&gt;
&lt;P&gt;The file from which I have imported data into SAS has this format for DOB: mm-dd-yy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We put informat function in declaration part of the code, which is to say in input statement.&amp;nbsp; What is the role of it? Does informat change mm-dd-yy to a number so SAS can understand DOB?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise me.&lt;/P&gt;
&lt;P&gt;Blue Blue Sky&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>Sat, 24 Apr 2021 04:10:56 GMT</pubDate>
    <dc:creator>GN0001</dc:creator>
    <dc:date>2021-04-24T04:10:56Z</dc:date>
    <item>
      <title>Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736711#M229558</link>
      <description>&lt;P&gt;Hello team,&lt;/P&gt;
&lt;P&gt;I have the coes as below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;LibName MyLibName 'Path';&lt;BR /&gt;Infile "Path";&lt;BR /&gt;Input Id$ sex$ DOB pdX Dx_3 Dx_4;&lt;BR /&gt;Informat DOB Date9.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know SAS sees the date as number of days away far from January 1st, 1960.&lt;/P&gt;
&lt;P&gt;The file from which I have imported data into SAS has this format for DOB: mm-dd-yy.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We put informat function in declaration part of the code, which is to say in input statement.&amp;nbsp; What is the role of it? Does informat change mm-dd-yy to a number so SAS can understand DOB?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please advise me.&lt;/P&gt;
&lt;P&gt;Blue Blue Sky&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>Sat, 24 Apr 2021 04:10:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736711#M229558</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-24T04:10:56Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736719#M229559</link>
      <description>&lt;P&gt;Here is a sample program you can use to answer your own question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  input date ;
  informat date mmddyy10.;
  put 'Using no assigned format: ' @28 date=;
  put 'Using date9 format: '       @28 date=date9.;
  put 'Using mmddyy10. format: '   @28 date=mmddyy10.;
datalines;
04/24/2021
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which generates on the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Using no assigned format:  date=22394
Using date9 format:        date=24APR2021
Using mmddyy10. format:    date=04/24/2021
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see, by using the informat mmddyy10., SAS converted the external string "04/24/2021" to an internal value (22394), which appears on the log according to the assigned format (not informat).used in the PUT statement.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 04:47:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736719#M229559</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-04-24T04:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736720#M229560</link>
      <description>&lt;P&gt;First of all, you have an INFORMAT&amp;nbsp;&lt;EM&gt;statement&lt;/EM&gt;, not a&amp;nbsp;&lt;EM&gt;function&lt;/EM&gt; (there is no INFORMAT function).&lt;/P&gt;
&lt;P&gt;You need to use an informat that matches the format of your date.&lt;/P&gt;
&lt;P&gt;DATE9 expects ddmmmyyyy, where the month is written as a 3-character abbreviation. From your description, I take it that you should use the MMDDYY8. informat.&lt;/P&gt;
&lt;P&gt;Which idiot sends you dates with 2-digit years? With 4-digit years, use MMDDYY10.&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 04:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736720#M229560</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-24T04:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736763#M229590</link>
      <description>Hello Mkeintz,&lt;BR /&gt;&lt;BR /&gt;What is the role informat here? Does it convert a date such as 04-22-2021 to number so SAS can read the date variable? If we remove informat statement, sas is not able to read the date. The log shows .. &lt;BR /&gt;I found this: SAS Informat Statement SAS Informat is an instruction that SAS used to read data values into a variable.&lt;BR /&gt;I know format displays date in a way that we can understand.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Blue Sky&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Apr 2021 18:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736763#M229590</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-24T18:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736764#M229591</link>
      <description>Hello Kurtbremser,&lt;BR /&gt;I have a course in SAS and the instructor says it is a function as far as I hear it. I agree with you, it is not a function.&lt;BR /&gt;Thanks for your response. Your explanation that "the informat that matches the format of my date:" is helpful.&lt;BR /&gt;Now, I understood what informat does, I think I need to understand some from the backend of SAS. When SAS reads the data in PDV, what does informat play in this scenario? &lt;BR /&gt;Regards,&lt;BR /&gt;Blue Blue Sky</description>
      <pubDate>Sat, 24 Apr 2021 18:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736764#M229591</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-24T18:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736765#M229592</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hello Mkeintz,&lt;BR /&gt;&lt;BR /&gt;What is the role informat here? Does it convert a date such as 04-22-2021 to number so SAS can read the date variable? If we remove informat statement, sas is not able to read the date. The log shows .. &lt;BR /&gt;I found this: SAS Informat Statement SAS Informat is an instruction that SAS used to read data values into a variable.&lt;BR /&gt;I know format displays date in a way that we can understand.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Blue Sky&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your file does not have a date, it has a string of text characters.&amp;nbsp; &amp;nbsp;The role of the INFORMAT statement is to attach an informat specification to a variable.&amp;nbsp; So that when the INPUT statement does not explicitly state what informat to use for that variable the INPUT statement will use the informat that is attached to the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Remember:&amp;nbsp; &lt;STRONG&gt;Informats convert text to values.&amp;nbsp; Formats convert values to text.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 18:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736765#M229592</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-04-24T18:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736767#M229594</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;When SAS reads the data in PDV, what does informat play in this scenario? &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The informat is a template that tells SAS how to convert a part of the input stream to a data value for use in the data step. Some are very simple (e.g. $10., which reads the next 10 characters), others quite complex (like the date, time and datetime informats). $10. will read anything, while MMDDYY10. expects a valid date (although it tolerates a wide range of separators and dates shorter than 10 characters).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data check;
input date mmddyy10.;
format date yymmdd10.;
datalines;
02-03-2021
02/03/2021
02 03 2021
02.03.2021
02_03_2021
02:03:2021
2/3/2021
02032021
232021
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(only the last one will be rejected)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your instructor insists on calling INFORMAT a &lt;EM&gt;function&lt;/EM&gt;, direct her/him &lt;A href="https://documentation.sas.com/doc/de/pgmsascdc/9.4_3.4/lefunctionsref/p1q8bq2v0o11n6n1gpij335fqpph.htm" target="_blank" rel="noopener"&gt;here&lt;/A&gt;, and ask where the function can be found &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Apr 2021 19:04:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736767#M229594</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-04-24T19:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736802#M229609</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/202329"&gt;@GN0001&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;"&lt;EM&gt;When SAS reads the data in PDV, what does informat play in this scenario?&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Some docu &lt;A href="https://documentation.sas.com/doc/en/lrcon/9.4/p18vk5t9cwort1n18g7zg2no6tr4.htm" target="_self"&gt;here&lt;/A&gt; - may-be too much for you right now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When SAS reads an external file then:&lt;/P&gt;
&lt;P&gt;1. Reads a record into the input buffer&lt;/P&gt;
&lt;P&gt;2. Reads the data in the input buffer into the PDV&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The input buffer just got one record from your external data "as is" loaded into memory.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The PDV got one row/obs of your data in SAS variables.&lt;/P&gt;
&lt;P&gt;Options in the infile statement together with informats provide to SAS the instructions how to map (and convert) the data in the input buffer into SAS variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's say you've got in your external data a string like 05May2021&lt;/P&gt;
&lt;P&gt;In the input buffer this is still 05May2021&lt;/P&gt;
&lt;P&gt;In your input statement you've got now something like: mydate date9.&lt;/P&gt;
&lt;P&gt;The date9. informat provides to SAS the instruction how to read the string 05May2021 into SAS variable mydate. Using this informat SAS will convert the string 05May2021 into a SAS Date value which is the count of days since 1/1/1960 (=22405).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format instructs SAS how to print a value. Taking above example if you just print the values stored in variable mydate without a format then you will get 22405 - which is not human readable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A format of date9. (same name like the informat but you could also use some different format like ddmmyy10.) applied to variable mydate will print the same internal value of 22405 as 05May2021.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope above was helpful and didn't just confuse you.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Apr 2021 03:01:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736802#M229609</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-25T03:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736873#M229661</link>
      <description>Patrick,&lt;BR /&gt;This is nicely explained, thanks for it.&lt;BR /&gt;Blue Blue Sky</description>
      <pubDate>Sun, 25 Apr 2021 16:56:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736873#M229661</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-25T16:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: Informat</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736874#M229662</link>
      <description>Thanks for your all inputs that got me closer to what I was looking for.&lt;BR /&gt;Blue Blue Sky</description>
      <pubDate>Sun, 25 Apr 2021 16:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Informat/m-p/736874#M229662</guid>
      <dc:creator>GN0001</dc:creator>
      <dc:date>2021-04-25T16:57:40Z</dc:date>
    </item>
  </channel>
</rss>

