<?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 Proc import issue in Unix SAS in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24485#M5532</link>
    <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I met with a problem when using proc import in Unix SAS, the last variable can not be read correct, here is the code:&lt;BR /&gt;
&lt;BR /&gt;
proc import out=t1&lt;BR /&gt;
            datafile="/home/test.csv" &lt;BR /&gt;
            dbms=csv replace;&lt;BR /&gt;
            getnames=yes;&lt;BR /&gt;
            datarow=2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc contents data=t1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The dataset test.csv is &lt;BR /&gt;
id	state	sex	age&lt;BR /&gt;
1	VA	M	26&lt;BR /&gt;
2	DC	F	27&lt;BR /&gt;
3	CA	F	23&lt;BR /&gt;
4	FL	M	29&lt;BR /&gt;
5	IL	F	31&lt;BR /&gt;
&lt;BR /&gt;
The SAS log reads as:&lt;BR /&gt;
&lt;BR /&gt;
1          proc import out=t1&lt;BR /&gt;
2                      datafile="/home/test.csv"&lt;BR /&gt;
3                      dbms=csv replace;&lt;BR /&gt;
4                      getnames=yes;&lt;BR /&gt;
5                      datarow=2;&lt;BR /&gt;
6          run;&lt;BR /&gt;
&lt;BR /&gt;
Name age&lt;BR /&gt;
 is not a valid SAS name.&lt;BR /&gt;
Problems were detected with provided names.  See LOG. &lt;BR /&gt;
7           /**********************************************************************&lt;BR /&gt;
8           *   PRODUCT:   SAS&lt;BR /&gt;
9           *   VERSION:   9.1&lt;BR /&gt;
10          *   CREATOR:   External File Interface&lt;BR /&gt;
11          *   DATE:      28APR09&lt;BR /&gt;
12          *   DESC:      Generated SAS Datastep Code&lt;BR /&gt;
13          *   TEMPLATE SOURCE:  (None Specified.)&lt;BR /&gt;
14          ***********************************************************************/&lt;BR /&gt;
15             data T1                                          ;&lt;BR /&gt;
16             %let _EFIERR_ = 0; /* set the ERROR detection macro variable */&lt;BR /&gt;
17             infile '/home/test.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;&lt;BR /&gt;
18                informat id best32. ;&lt;BR /&gt;
19                informat state $2. ;&lt;BR /&gt;
20                informat sex $1. ;&lt;BR /&gt;
21                informat VAR4 $3. ;&lt;BR /&gt;
22                format id best12. ;&lt;BR /&gt;
23                format state $2. ;&lt;BR /&gt;
24                format sex $1. ;&lt;BR /&gt;
25                format VAR4 $3. ;&lt;BR /&gt;
26             input&lt;BR /&gt;
27                         id&lt;BR /&gt;
28                         state $&lt;BR /&gt;
29                         sex $&lt;BR /&gt;
30                         VAR4 $&lt;BR /&gt;
31             ;&lt;BR /&gt;
32             if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */&lt;BR /&gt;
33             run;&lt;BR /&gt;
&lt;BR /&gt;
and proc contents list as:&lt;BR /&gt;
&lt;BR /&gt;
 Alphabetic List of Variables and Attributes&lt;BR /&gt;
 &lt;BR /&gt;
#    Variable    Type    Len    Format     Informat&lt;BR /&gt;
&lt;BR /&gt;
4    VAR4        Char      3    $3.        $3.     &lt;BR /&gt;
1    id          Num       8    BEST12.    BEST32. &lt;BR /&gt;
3    sex         Char      1    $1.        $1.     &lt;BR /&gt;
2    state       Char      2    $2.        $2.  &lt;BR /&gt;
&lt;BR /&gt;
You can see the last variable age is not read correctly: first it failed to import the variable name age but replaced with VAR4, second it is read as character in stead of numeric.&lt;BR /&gt;
&lt;BR /&gt;
Last time I used infile to read the data there was an issue with the last variable too, data_null_; kindly advised adding termstr=crlf to resolve the problem. I doubt this issue is an integration issue(Unix SAS with PC) too, can anybody suggest how to get the issue resolved?&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for attention and help!</description>
    <pubDate>Tue, 28 Apr 2009 19:00:24 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-04-28T19:00:24Z</dc:date>
    <item>
      <title>Proc import issue in Unix SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24485#M5532</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
I met with a problem when using proc import in Unix SAS, the last variable can not be read correct, here is the code:&lt;BR /&gt;
&lt;BR /&gt;
proc import out=t1&lt;BR /&gt;
            datafile="/home/test.csv" &lt;BR /&gt;
            dbms=csv replace;&lt;BR /&gt;
            getnames=yes;&lt;BR /&gt;
            datarow=2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc contents data=t1;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The dataset test.csv is &lt;BR /&gt;
id	state	sex	age&lt;BR /&gt;
1	VA	M	26&lt;BR /&gt;
2	DC	F	27&lt;BR /&gt;
3	CA	F	23&lt;BR /&gt;
4	FL	M	29&lt;BR /&gt;
5	IL	F	31&lt;BR /&gt;
&lt;BR /&gt;
The SAS log reads as:&lt;BR /&gt;
&lt;BR /&gt;
1          proc import out=t1&lt;BR /&gt;
2                      datafile="/home/test.csv"&lt;BR /&gt;
3                      dbms=csv replace;&lt;BR /&gt;
4                      getnames=yes;&lt;BR /&gt;
5                      datarow=2;&lt;BR /&gt;
6          run;&lt;BR /&gt;
&lt;BR /&gt;
Name age&lt;BR /&gt;
 is not a valid SAS name.&lt;BR /&gt;
Problems were detected with provided names.  See LOG. &lt;BR /&gt;
7           /**********************************************************************&lt;BR /&gt;
8           *   PRODUCT:   SAS&lt;BR /&gt;
9           *   VERSION:   9.1&lt;BR /&gt;
10          *   CREATOR:   External File Interface&lt;BR /&gt;
11          *   DATE:      28APR09&lt;BR /&gt;
12          *   DESC:      Generated SAS Datastep Code&lt;BR /&gt;
13          *   TEMPLATE SOURCE:  (None Specified.)&lt;BR /&gt;
14          ***********************************************************************/&lt;BR /&gt;
15             data T1                                          ;&lt;BR /&gt;
16             %let _EFIERR_ = 0; /* set the ERROR detection macro variable */&lt;BR /&gt;
17             infile '/home/test.csv' delimiter = ',' MISSOVER DSD lrecl=32767 firstobs=2 ;&lt;BR /&gt;
18                informat id best32. ;&lt;BR /&gt;
19                informat state $2. ;&lt;BR /&gt;
20                informat sex $1. ;&lt;BR /&gt;
21                informat VAR4 $3. ;&lt;BR /&gt;
22                format id best12. ;&lt;BR /&gt;
23                format state $2. ;&lt;BR /&gt;
24                format sex $1. ;&lt;BR /&gt;
25                format VAR4 $3. ;&lt;BR /&gt;
26             input&lt;BR /&gt;
27                         id&lt;BR /&gt;
28                         state $&lt;BR /&gt;
29                         sex $&lt;BR /&gt;
30                         VAR4 $&lt;BR /&gt;
31             ;&lt;BR /&gt;
32             if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */&lt;BR /&gt;
33             run;&lt;BR /&gt;
&lt;BR /&gt;
and proc contents list as:&lt;BR /&gt;
&lt;BR /&gt;
 Alphabetic List of Variables and Attributes&lt;BR /&gt;
 &lt;BR /&gt;
#    Variable    Type    Len    Format     Informat&lt;BR /&gt;
&lt;BR /&gt;
4    VAR4        Char      3    $3.        $3.     &lt;BR /&gt;
1    id          Num       8    BEST12.    BEST32. &lt;BR /&gt;
3    sex         Char      1    $1.        $1.     &lt;BR /&gt;
2    state       Char      2    $2.        $2.  &lt;BR /&gt;
&lt;BR /&gt;
You can see the last variable age is not read correctly: first it failed to import the variable name age but replaced with VAR4, second it is read as character in stead of numeric.&lt;BR /&gt;
&lt;BR /&gt;
Last time I used infile to read the data there was an issue with the last variable too, data_null_; kindly advised adding termstr=crlf to resolve the problem. I doubt this issue is an integration issue(Unix SAS with PC) too, can anybody suggest how to get the issue resolved?&lt;BR /&gt;
&lt;BR /&gt;
Thanks so much for attention and help!</description>
      <pubDate>Tue, 28 Apr 2009 19:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24485#M5532</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-28T19:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue in Unix SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24486#M5533</link>
      <description>I suspect the .csv file is coming from a PC.  If so, this is a common problem.  The end-of-line marker for a text file is different on a PC than it is on Unix.&lt;BR /&gt;
&lt;BR /&gt;
Run the doc2unix utility on Unix to get the right end of line and then you can get the data in reasonably.</description>
      <pubDate>Tue, 28 Apr 2009 19:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24486#M5533</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-04-28T19:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue in Unix SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24487#M5534</link>
      <description>Yes the csv file is from PC, can you advise in more detail how to run the doc2unix utility?</description>
      <pubDate>Tue, 28 Apr 2009 20:01:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24487#M5534</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-28T20:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue in Unix SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24488#M5535</link>
      <description>Hello Beickham,&lt;BR /&gt;
&lt;BR /&gt;
Doc made a little spelling mistake. It is dos2unix.&lt;BR /&gt;
&lt;BR /&gt;
&lt;I&gt;"DOS text files traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters while Unix text files traditionally have LFs (line feeds) to terminate each line"&lt;/I&gt; (cited from Ubuntu/tofromdos documentation)&lt;BR /&gt;
&lt;BR /&gt;
dos2unix will convert CR/LF to LFs.&lt;BR /&gt;
&lt;BR /&gt;
If you are running sas under debian/linux, the installation of the tofromdos package will provide you with the dos2unix and unix2dos utilities.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
&lt;BR /&gt;
yoba</description>
      <pubDate>Tue, 28 Apr 2009 20:33:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24488#M5535</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-28T20:33:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc import issue in Unix SAS</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24489#M5536</link>
      <description>Thanks for the catch.  Our Unix Admin had already installed it the first time I needed it.&lt;BR /&gt;
&lt;BR /&gt;
I think the syntax is&lt;BR /&gt;
dos2unix pcfilename &amp;gt; unixfilename&lt;BR /&gt;
It follows the usual Unix command conventions. If it is already installed, it is also likely that the documentation is in your man pages.&lt;BR /&gt;
&lt;BR /&gt;
If it is easier, you can download a PC version of the utility and do the conversion before moving it to the Unix box.</description>
      <pubDate>Wed, 29 Apr 2009 01:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Proc-import-issue-in-Unix-SAS/m-p/24489#M5536</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2009-04-29T01:41:34Z</dc:date>
    </item>
  </channel>
</rss>

