<?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 free format nonstandard data input in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402543#M97760</link>
    <description>&lt;P&gt;So I am trying to import a .txt comma dlm file to sas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have everything correct, except some of the birthdates are coming up as "invalid data" and its skipping over them.. oddly enough I think its all of the october birthdays.. i have provided a couple of attachments of the output and the code i have used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{this is not real data}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2147.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15734iDE381CD8247631E7/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2147.JPG" alt="IMG_2147.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2148.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15735i2110EC1C7E60B40C/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2148.JPG" alt="IMG_2148.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 01:57:22 GMT</pubDate>
    <dc:creator>klinz1</dc:creator>
    <dc:date>2017-10-10T01:57:22Z</dc:date>
    <item>
      <title>free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402543#M97760</link>
      <description>&lt;P&gt;So I am trying to import a .txt comma dlm file to sas.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think I have everything correct, except some of the birthdates are coming up as "invalid data" and its skipping over them.. oddly enough I think its all of the october birthdays.. i have provided a couple of attachments of the output and the code i have used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{this is not real data}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2147.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15734iDE381CD8247631E7/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2147.JPG" alt="IMG_2147.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2148.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15735i2110EC1C7E60B40C/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2148.JPG" alt="IMG_2148.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:57:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402543#M97760</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402546#M97762</link>
      <description>&lt;P&gt;Did you mention informat for the date variable? you can try again with that mmddyy10. ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data yo;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;format DOB date9.;&lt;/P&gt;&lt;P&gt;informat&amp;nbsp;DOB mmddyy10.;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;INPUT ... DOB ..;&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 00:53:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402546#M97762</guid>
      <dc:creator>ali_jooan</dc:creator>
      <dc:date>2017-10-10T00:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402548#M97764</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/61852"&gt;@IF&lt;/a&gt; it's comma delimited why are you using&amp;nbsp;@/+1 to denote positions? You're mixing read in styles.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try removing the positional parameters.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would suggest using PROC IMPORT to read the data first, examine the log and then customize it as needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Please don't post images, post your code and log as text.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170633"&gt;@klinz1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;So I am trying to import a .txt comma dlm file to sas.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I have everything correct, except some of the birthdates are coming up as "invalid data" and its skipping over them.. oddly enough I think its all of the october birthdays.. i have provided a couple of attachments of the output and the code i have used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;{this is not real data}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks in advance&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2147.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15734iDE381CD8247631E7/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2147.JPG" alt="IMG_2147.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_2148.JPG" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15735i2110EC1C7E60B40C/image-size/small?v=v2&amp;amp;px=200" role="button" title="IMG_2148.JPG" alt="IMG_2148.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:04:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402548#M97764</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T01:04:43Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402549#M97765</link>
      <description>&lt;P&gt;in my "format" line i have the birthdate mmddyy10.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I found that if i remove the +1 from in front of birthdate all birthdates are imported, however, then the rows with salaries that are 6 numerics the birthdate moves to the hiredate and the hiredate moves to the termdate in the output..&amp;nbsp;&lt;/P&gt;&lt;P&gt;suggestions?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:06:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402549#M97765</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402552#M97766</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170633"&gt;@klinz1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;wrote: You've got a comma separated source file which you can read in easily using LIST input style only. Don't use any other styles and though remove all your&amp;nbsp;@ and + which move the input pointer.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:12:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402552#M97766</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-10T01:12:41Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402555#M97768</link>
      <description>&lt;P&gt;my bad.. I've never used this forum before..&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so the code that i am now using looks like:&amp;nbsp;&lt;/P&gt;&lt;DIV class="gmail_default"&gt;data employee;&lt;BR /&gt;&amp;nbsp;infile ".txt." dlm="," dsd truncover;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;input id gender $1. salary dollar7. birthdate : mmddyy10. hiredate : mmddyy10. termdate : mmddyy10.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;maritalstat $1. +1 numdependents $1. +1 promostatus $1.;&lt;BR /&gt;&amp;nbsp;format salary dollar7. birthdate mmddyy10. hiredate mmddyy10. termdate mmddyy10.;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;it is importing all birthdates. however, now when the salary is 6 numerics instead of 5, like the first 2 lines in the txt photo, the birthdate is showing up as the hiredate, and the hiredate is showing us as the termdate..&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;suggestions?&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:16:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402555#M97768</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402556#M97769</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170633"&gt;@klinz1&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Why are you using&amp;nbsp;&lt;SPAN&gt;&lt;EM&gt;dollar7.&lt;/EM&gt; if your source data is not in this format?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:20:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402556#M97769</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-10T01:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402559#M97772</link>
      <description>&lt;P&gt;if i make it "salary 6." or "salary 10-15" only the salaries that are 6 characters are imported.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402559#M97772</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402560#M97773</link>
      <description>&lt;P&gt;I sort of commend you for trying to understand your code and fix it. At the same time, the solution recommended&amp;nbsp;is still valid. Did you attempt that method?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;gt;I would suggest using PROC IMPORT to read the data first, examine the log and then customize it as needed.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To elaborate some more, PROC IMPORT generates a data step for the import of text files. This is essentially the code you're trying to write.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402560#M97773</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T01:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402561#M97774</link>
      <description>&lt;P&gt;the code i currently have input is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="gmail_default"&gt;data employee;&lt;BR /&gt;&amp;nbsp;infile ".txt." dlm="," dsd truncover;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;input id gender $ salary 6. birthdate : mmddyy10. hiredate : mmddyy10. termdate : mmddyy10.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;marital tat $ numdependents promostatus ;&lt;BR /&gt;&amp;nbsp;format birthdate mmddyy10. hiredate mmddyy10. termdate mmddyy10.;&lt;BR /&gt;run;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;the result did not output any salaries that were 5 characters. and the rows with salaries that are 6 numerics are moved over one, i.e. birthdate is showing up as hiredate and hiredate is showing up as termdate.&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="gmail_default"&gt;other than that its correct.. lol&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402561#M97774</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402562#M97775</link>
      <description>&lt;P&gt;lol, thank you.&amp;nbsp;&lt;/P&gt;&lt;P&gt;i will try that. however, this is for an assignment and we were explicitly told NOT to use proc import.. unfortunately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all your help, if you have a suggestion on how to fix the salary problem I'm now having that would be appreciated as well!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 01:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402562#M97775</guid>
      <dc:creator>klinz1</dc:creator>
      <dc:date>2017-10-10T01:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402571#M97779</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170633"&gt;@klinz1&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;lol, thank you.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i will try that. however, this is for an assignment and we were explicitly told NOT to use proc import.. unfortunately.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for all your help, if you have a suggestion on how to fix the salary problem I'm now having that would be appreciated as well!&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This means you don't put a PROC IMPORT in your answer, it doesn't mean you can't use it to see what code you need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Don't use the : operator within the INPUT, unless you're 100% sure you understand what it's doing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Create an INFORMAT statement BEFORE your INPUT statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3. Create a FORMAT statement&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4. Make your INPUT statement only include the list of variables, everything else is prespecified. To see an example, see the code from a PROC IMPORT.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 02:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402571#M97779</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-10T02:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: free format nonstandard data input</title>
      <link>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402594#M97786</link>
      <description>&lt;P&gt;Do not use formatted input to read a delimited list, instead use list mode. Read the manual on the INPUT statement and it will explain the different input styles.&lt;/P&gt;
&lt;P&gt;Define your variables before you use them in other statements. That includes before you use them in FORMAT, INFORMAT and INPUT statements. Then you are sure that your variables will be defined as you want them.&amp;nbsp; It also makes it easier to use list mode input style since you do not have to worry about adding informats or column locations to the INPUT to help SAS guess how you wanted the variable defined.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data employee;
  infile "myfile.txt" dlm="," dsd truncover;
  length id 8 gender $1 salary birthdate hiredate termdate 8
         maritalstat numdependents promostatus $1
  ;
  input id -- promostatus ;
  informat salary dollar7. birthdate hiredate termdate mmddyy10.;
  format salary dollar7. birthdate hiredate termdate mmddyy10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note is does not matter where you put the FORMAT and INFORMAT statements as those are attributes of the variables that are set when the data step is compiled and not when it executes.&amp;nbsp; (But note that if do put them BEFORE you have defined the variables via a LENGTH, ATTRIB or setting an existing dataset then SAS will add the variables to the dataset based on the format you have attached since they will be the first place you have used the variable. And it will impact the order that the variables are in the dataset.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 04:25:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/free-format-nonstandard-data-input/m-p/402594#M97786</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-10T04:25:43Z</dc:date>
    </item>
  </channel>
</rss>

