<?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: How to read non-standard dOutside/Open Areas in SAS in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694521#M211821</link>
    <description>&lt;P&gt;Hi Jedi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your code but it still didnt work in SAS...&lt;/P&gt;&lt;P&gt;I have trouble reading two different formats of date and&amp;nbsp;FATALITY_LOCATION in SAS&lt;/P&gt;&lt;P&gt;I intended to read the dates in AU format and&amp;nbsp;&lt;STRONG&gt;FATALITY_LOCATION properly..&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have been trying to work it out for a few hours and still couldnt work it out.. sigh&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Oct 2020 12:10:34 GMT</pubDate>
    <dc:creator>rmit387</dc:creator>
    <dc:date>2020-10-27T12:10:34Z</dc:date>
    <item>
      <title>How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694496#M211810</link>
      <description>&lt;DIV class="sasError"&gt;Hi&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;I have a csv file needed to read in SAS. I struggled to read&amp;nbsp; FATALITY_LOCATION&amp;nbsp; (please see attachment)&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;options LOCALE=en_AU;&lt;BR /&gt;data fatalities;&lt;BR /&gt;infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;&lt;BR /&gt;input FATALITY_ID EVENT_ID FATALITY_TYPE$ FATALITY_DATE FATALITY_AGE FATALITY_SEX$ FATALITY_LOCATION$;&lt;BR /&gt;informat FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE ddmmyy10. FATALITY_AGE FATALITY_SEX$ FATALITY_LOCATION $80.;&lt;BR /&gt;format FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE date9. FATALITY_AGE FATALITY_SEX$ FATALITY_LOCATION $80.;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;But then it came out with error message stated below:&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;STRONG&gt;ERROR 22-322: Expecting a format name.&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&lt;STRONG&gt;ERROR 76-322: Syntax error, statement will be ignored. &lt;/STRONG&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;How to read to Outside/Open Areas in SAS?&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;Thanks in advance!!&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="sasError"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694496#M211810</guid>
      <dc:creator>rmit387</dc:creator>
      <dc:date>2020-10-27T11:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694503#M211814</link>
      <description>&lt;P&gt;See my comments:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options LOCALE=en_AU;
data fatalities;
infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;
informat
  FATALITY_ID
  EVENT_ID
  FATALITY_TYPE
    $10. /* if this is not meant for the previous three variables, give each its own informat */
  FATALITY_DATE ddmmyy10.
  FATALITY_AGE /* if this is numeric, add a humeric informat here */
  FATALITY_SEX $xxx.  /* insert proper length here */
  FATALITY_LOCATION $80.
;
format
  FATALITY_DATE date9.
  /* no formats needed for pure numbers or strings */
;
input
  FATALITY_ID
  EVENT_ID
  FATALITY_TYPE
  FATALITY_DATE
  FATALITY_AGE
  FATALITY_SEX
  FATALITY_LOCATION
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In case of problems, post the log by copy/pasting it into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/E0BB18E7DAA53C21BC28740CEA0E38DA/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 11:39:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694503#M211814</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-27T11:39:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694516#M211819</link>
      <description>&lt;P&gt;For future postings, when you share data with your question, please consider providing the data in machine-readable format (like CSV, in this case) instead of PDF. Here's how I identified the problem:&lt;BR /&gt;1. I pasted your code into SAS Studio and used the FORMAT CODE feature to make it more readable.&lt;/P&gt;
&lt;P&gt;2. Reviewing the formatted code, the issue is easier to spot. The INFORMAT and FORMAT statements contain the entry &lt;CODE class=" language-sas"&gt;&lt;STRONG&gt;FATALITY_SEX$&lt;/STRONG&gt;&lt;/CODE&gt;&amp;nbsp;which is causing your error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fatalities;
   infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;
   input FATALITY_ID EVENT_ID FATALITY_TYPE$ FATALITY_DATE FATALITY_AGE 
         FATALITY_SEX$ FATALITY_LOCATION$;
   informat FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE ddmmyy10. 
            FATALITY_AGE &lt;STRONG&gt;FATALITY_SEX$ &lt;/STRONG&gt;FATALITY_LOCATION $80.;
   format FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE date9. 
          FATALITY_AGE &lt;STRONG&gt;FATALITY_SEX$&lt;/STRONG&gt; FATALITY_LOCATION $80.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;A $ is not acceptable to specify the format/informat here. A valid format specification is required for the FORMAT statement, and a valid informat specification on the INFORMAT statement. Something like this would work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fatalities;&lt;BR /&gt;   infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;
   input FATALITY_ID EVENT_ID FATALITY_TYPE$ FATALITY_DATE FATALITY_AGE 
         FATALITY_SEX$ FATALITY_LOCATION$;
   informat FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE ddmmyy10. 
            FATALITY_AGE &lt;STRONG&gt;FATALITY_SEX $1.&lt;/STRONG&gt; FATALITY_LOCATION $80.;
   format FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE date9. 
          FATALITY_AGE &lt;STRONG&gt;FATALITY_SEX $1.&lt;/STRONG&gt; FATALITY_LOCATION $80.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With an INFORMAT statement provided&lt;STRONG&gt;,&lt;/STRONG&gt; the &lt;STRONG&gt;$&lt;/STRONG&gt; characters on the INPUT statement are no longer required to ensure values are read in as character, so they could be removed. And finally, I highly recommend that you don't apply formats to character values - it can make it difficult to view the actual values during downstream processing. So my final recommendation would be something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fatalities;
   infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;
   informat FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE ddmmyy10. 
            FATALITY_AGE FATALITY_SEX $1. FATALITY_LOCATION $80.;
   format FATALITY_DATE date9.;
   input FATALITY_ID EVENT_ID FATALITY_TYPE FATALITY_DATE FATALITY_AGE 
         FATALITY_SEX FATALITY_LOCATION$;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May the SAS be with you!&lt;/P&gt;
&lt;P&gt;Mark&lt;BR /&gt;&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>Tue, 27 Oct 2020 12:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694516#M211819</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-10-27T12:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694521#M211821</link>
      <description>&lt;P&gt;Hi Jedi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your code but it still didnt work in SAS...&lt;/P&gt;&lt;P&gt;I have trouble reading two different formats of date and&amp;nbsp;FATALITY_LOCATION in SAS&lt;/P&gt;&lt;P&gt;I intended to read the dates in AU format and&amp;nbsp;&lt;STRONG&gt;FATALITY_LOCATION properly..&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Have been trying to work it out for a few hours and still couldnt work it out.. sigh&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694521#M211821</guid>
      <dc:creator>rmit387</dc:creator>
      <dc:date>2020-10-27T12:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694542#M211827</link>
      <description>&lt;P&gt;I downloaded your csv file to my University Edition and ran this with success:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fatalities;
infile "/folders/myfolders/F1.csv" delimiter="," firstobs=2 dsd truncover;
informat
  FATALITY_ID $5.
  EVENT_ID $6.
  FATALITY_TYPE $1.
  FATALITY_DATE mmddyy10.
  FATALITY_AGE 3.
  FATALITY_SEX $1.
  FATALITY_LOCATION $80.
;
format
  FATALITY_DATE yymmdd10.
;
input
  FATALITY_ID
  EVENT_ID
  FATALITY_TYPE
  FATALITY_DATE
  FATALITY_AGE
  FATALITY_SEX
  FATALITY_LOCATION
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that the dates are in MMDDYY format in your CSV.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Oct 2020 12:48:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694542#M211827</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-10-27T12:48:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to read non-standard dOutside/Open Areas in SAS</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694803#M211928</link>
      <description>&lt;P&gt;Having the actual data to work with makes a big difference&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;. So, here are a few lines from the CSV:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FATALITY_ID,EVENT_ID,FATALITY_TYPE,FATALITY_DATE,FATALITY_AGE,FATALITY_SEX,FATALITY_LOCATION
38341,817354,D,&lt;STRONG&gt;06/06/2019&lt;/STRONG&gt;,97,M,Outside/Open Areas
38480,819069,D,&lt;STRONG&gt;06/09/2019&lt;/STRONG&gt;,45,M,Vehicle/Towed Trailer
38532,820152,D,&lt;STRONG&gt;06/20/2019&lt;/STRONG&gt;,,M,In Water&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It's clear that these dates are written in the typical US format, month/day/year - or MMDDYY in SAS-speak. The dates are 10 characters wide, so we must use the INFORMAT MMDDYY10. to properly read the values.&amp;nbsp; Once the proper INFORMAT for the date is supplied on the INFORMAT statement, it should work just fine:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data fatalities;
   infile "/group/FATALITIES.csv" delimiter="," firstobs=2 dsd missover;
   informat FATALITY_ID EVENT_ID FATALITY_TYPE $10. FATALITY_DATE &lt;STRONG&gt;mmddyy10.&lt;/STRONG&gt; 
            FATALITY_AGE FATALITY_SEX $1. FATALITY_LOCATION $80.;
   format FATALITY_DATE date9.;
   input FATALITY_ID EVENT_ID FATALITY_TYPE FATALITY_DATE FATALITY_AGE 
         FATALITY_SEX FATALITY_LOCATION$;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;May the SAS be with you!&lt;BR /&gt;Mark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Oct 2020 11:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-read-non-standard-dOutside-Open-Areas-in-SAS/m-p/694803#M211928</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-10-28T11:16:12Z</dc:date>
    </item>
  </channel>
</rss>

