<?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 correct a text file on sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241112#M44639</link>
    <description>&lt;P&gt;This is sounding a bit like homework now...regardless, it may help if you attach a sample of the text file.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Dec 2015 06:03:58 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-12-29T06:03:58Z</dc:date>
    <item>
      <title>How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241056#M44600</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to import the folliwing text file :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 x1 2 x2&lt;/P&gt;&lt;P&gt;10 11&lt;/P&gt;&lt;P&gt;20 21&lt;/P&gt;&lt;P&gt;30 31&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and must read it like this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;x1 x2&lt;/P&gt;&lt;P&gt;10 11&lt;/P&gt;&lt;P&gt;20 21&lt;/P&gt;&lt;P&gt;30 31&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;I am a complete beginner and couldn't find how to do it through the tutorials etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241056#M44600</guid>
      <dc:creator>MakKK</dc:creator>
      <dc:date>2015-12-28T19:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241057#M44601</link>
      <description>Did you try using the point and click interface? Which tool are you using?&lt;BR /&gt;&lt;BR /&gt;Here's a link to examples on importing text files:&lt;BR /&gt;&lt;A href="http://www.ats.ucla.edu/stat/sas/faq/read_delim.htm" target="_blank"&gt;http://www.ats.ucla.edu/stat/sas/faq/read_delim.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Additionally, the SAS Programming 1 course is freely available.</description>
      <pubDate>Mon, 28 Dec 2015 19:19:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241057#M44601</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-28T19:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241059#M44602</link>
      <description>&lt;P&gt;Is the first line the variable names?&lt;/P&gt;
&lt;P&gt;1 is not a valid SAS name, and I guess that's why you want to remove it.&lt;/P&gt;
&lt;P&gt;My&amp;nbsp;suggestion is to just skip line 1 in your import, and define the variable names explicitly.&lt;/P&gt;
&lt;P&gt;Tutorials/samples to look for - use key words "data step" "infile" input".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:23:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241059#M44602</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-12-28T19:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241061#M44603</link>
      <description>&lt;P&gt;Here is my program :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Filename Fichier "/folders/myshortcuts/desktop/donnees-brutes.txt";&lt;/P&gt;&lt;P&gt;Data don;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Infile Fichier Firstobs = 2;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Input 1 x1 2 x2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it tells me that there is a problem with my syntax because indeed the variables are messed up...&lt;/P&gt;&lt;P&gt;Do you have a solution so I can tell SAS to drop the "1" and "2"?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241061#M44603</guid>
      <dc:creator>MakKK</dc:creator>
      <dc:date>2015-12-28T19:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241062#M44604</link>
      <description>&lt;P&gt;Yes these are the variables, and i must find a general solution, regardless of the number of variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any tricks?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:31:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241062#M44604</guid>
      <dc:creator>MakKK</dc:creator>
      <dc:date>2015-12-28T19:31:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241064#M44606</link>
      <description>&lt;P&gt;Hm, do you mean that you always get files with an extra number in the first&amp;nbsp;position of the file?&lt;/P&gt;
&lt;P&gt;One (preferred) option is to have the files created for you with a different layout.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You&amp;nbsp;could perhaps a script (SAS or DOS/shell) that removes that prior to import it to SAS?&lt;/P&gt;
&lt;P&gt;By "general solution", does it mean you wish not to specify variable names in your import program,&amp;nbsp;they always should be assigned automatically? When building robust system best practice would to explicitly define record layout. Automation may sound simple, but will often lead to ad-hoc post-import-programming.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:44:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241064#M44606</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-12-28T19:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241065#M44607</link>
      <description>I don't quite understand what you mean that the program has to work as a "general solution". If the first "row" of your file contains the variable names to use and the data starts on row 2, then you will need to make 2 "reads" of the file. The first program will only read row 1 to determine how many variables/columns are on the rest of the rows and then the second program will use the information from the first row in an INPUT statement.&lt;BR /&gt;&lt;BR /&gt;  This will probably involve using a macro program, but the best suggestion I have is to write the whole set of programs first to make sure you really understand how to write the program before introducing anything to do with macro processing.&lt;BR /&gt; &lt;BR /&gt;  Also suggestion you read the rules for naming SAS variables. SAS variable names cannot start with a number, so the INPUT statement you show will error out because you cannot have a variable named "1" or "2". &lt;BR /&gt;&lt;BR /&gt;cynthia</description>
      <pubDate>Mon, 28 Dec 2015 19:44:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241065#M44607</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2015-12-28T19:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241066#M44608</link>
      <description>&lt;P&gt;It sounds like you just need a small change to your INPUT statement, making it:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;input x1 x2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have the possibility of missing values in your data it will get more complex. &amp;nbsp;But let's see if that's actually a problem first.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:49:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241066#M44608</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-12-28T19:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241068#M44609</link>
      <description>&lt;P&gt;Yes it seems I have to use something called %INPUT, &amp;nbsp;which will read my data for a second time, but I do not understand how it works.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 19:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241068#M44609</guid>
      <dc:creator>MakKK</dc:creator>
      <dc:date>2015-12-28T19:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241072#M44610</link>
      <description>&lt;P&gt;Actually I am supposed to find something like this :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Filename Fichier "/folders/myshortcuts/desktop/donnes-brutes.txt";&lt;BR /&gt;Data _null_ ;&lt;BR /&gt;set MAK;&lt;BR /&gt;Infile Fichier Firstobs = 2;&lt;BR /&gt;Input @@x1 @@x2;&lt;BR /&gt;If type= "NUM" then input @@x1;&lt;BR /&gt;else input @@x2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%include Fichier;&lt;BR /&gt;filename Fichier;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But that's not right..&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Dec 2015 20:03:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241072#M44610</guid>
      <dc:creator>MakKK</dc:creator>
      <dc:date>2015-12-28T20:03:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241088#M44622</link>
      <description>&lt;P&gt;If there are not too many variables in the file, that would be easy, otherwise you need change that file .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
infile '/folders/myfolders/temp.txt' firstobs=2 dlm=' ';
input x1 x2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Dec 2015 01:25:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241088#M44622</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-12-29T01:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241110#M44637</link>
      <description>&lt;P&gt;Is below doing what you're looking for or is there something else required with your real data?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data don;
  /*Infile Fichier Firstobs = 2 truncover dlm=' ' dsd; */
  Infile datalines Firstobs = 2 truncover dlm=' ' dsd;
  Input x1 x2;
  datalines;
1 x1 2 x2
10 11
20 21
30 31
;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Dec 2015 05:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241110#M44637</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-12-29T05:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to correct a text file on sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241112#M44639</link>
      <description>&lt;P&gt;This is sounding a bit like homework now...regardless, it may help if you attach a sample of the text file.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 06:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-correct-a-text-file-on-sas/m-p/241112#M44639</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-29T06:03:58Z</dc:date>
    </item>
  </channel>
</rss>

