BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
happy_sas_kitty
Obsidian | Level 7

Hello all,

I used the exact code here in https://documentation.sas.com/?docsetId=proc&docsetTarget=n1w1xy48wd290bn1mqalitn7wy13.htm&docsetVer...

 

My sas somehow cannot separate the txt file columns by tab.

My log is pasted below:

I changed text color for line 87-89. 

It seems that SAS knows that I'm using delimeter by tab.

It just fails to separate columns by '09'x

I'm using SAS Studio the web client with virtualbox win10

 

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc import datafile="/folders/myfolders/BOOK/cert/class.txt" out=class dbms=dlm replace;
 74         datarow=5;
 75         delimiter='09'x;
 76         run;
 
 NOTE: Unable to open parameter catalog: SASUSER.PARMS.PARMS.SLIST in update mode. Temporary parameter values will be saved to 
 WORK.PARMS.PARMS.SLIST.
 77          /**********************************************************************
 78          *   PRODUCT:   SAS
 79          *   VERSION:   9.4
 80          *   CREATOR:   External File Interface
 81          *   DATE:      03AUG20
 82          *   DESC:      Generated SAS Datastep Code
 83          *   TEMPLATE SOURCE:  (None Specified.)
 84          ***********************************************************************/
 85             data WORK.CLASS    ;
 86             %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
 87             infile '/folders/myfolders/BOOK/cert/class.txt' delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=5 ;
 88                informat Name_____Gender___Age $20. ;
 89                format Name_____Gender___Age $20. ;
 90             input
 91                         Name_____Gender___Age  $
 92             ;
 93             if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
 94             run;
 
 NOTE: The infile '/folders/myfolders/BOOK/cert/class.txt' is:
       Filename=/folders/myfolders/BOOK/cert/class.txt,
       Owner Name=root,Group Name=vboxsf,
       Access Permission=-rwxrwx---,
       Last Modified=02Aug2020:19:43:43,
       File Size (bytes)=1620
 
 NOTE: 16 records were read from the infile '/folders/myfolders/BOOK/cert/class.txt'.
       The minimum record length was 80.
       The maximum record length was 80.
 NOTE: The data set WORK.CLASS has 16 observations and 1 variables.
 NOTE: DATA statement used (Total process time):
       real time           0.01 seconds
       cpu time            0.00 seconds
       
 
 16 rows created in WORK.CLASS from /folders/myfolders/BOOK/cert/class.txt.
   
   
   
 NOTE: WORK.CLASS data set was successfully created.
 NOTE: The data set WORK.CLASS has 16 observations and 1 variables.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.11 seconds
       cpu time            0.05 seconds
       
 
 95         
 96         proc print data=class;
 97         run;
 
 NOTE: There were 16 observations read from the data set WORK.CLASS.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.05 seconds
       cpu time            0.05 seconds
       
 
 98         
 99         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 111        
1 ACCEPTED SOLUTION

Accepted Solutions
RichardDeVen
Barite | Level 11
Name_____Gender___Age

is a column name 'computed' by the External File Interface sub system invoked by Proc IMPORT when DBMS=DLM option is specified.

 

Because the expected tab delimiter was properly specified as 

delimiter='09'x;

The underscores underscore the fact that the data file very likely has spaces instead of tabs.  By default, non SAS-name characters in the header row are replaced with underscore character (_).  The spaces, not being a name character nor a delimiter are converted to underscore (_)

 

The underscores in the EFI computed column

Name_____Gender___Age
12345678901234567890123

indicates what I surmise as @happy_sas_kitty using a text editor configured with a tab stop setting of 3, and the editor replacing tabs with spaces upon File/Save.

View solution in original post

3 REPLIES 3
Shmuel
Garnet | Level 18

1) Have you run the proc export? You can ignore the note about the parameter catalog, as sas will overcome it. There is no log information expected of running the proc import.

 

2) Are you sure that the delimiter is '09'x and not '_' .

    Why have you coded lines:

informat Name_____Gender___Age $20. ;
 format Name_____Gender___Age $20. ;
     input
              Name_____Gender___Age  $
         ;

instead, just:

    input   Name $  Gender $  Age  $ ;

 

RichardDeVen
Barite | Level 11
Name_____Gender___Age

is a column name 'computed' by the External File Interface sub system invoked by Proc IMPORT when DBMS=DLM option is specified.

 

Because the expected tab delimiter was properly specified as 

delimiter='09'x;

The underscores underscore the fact that the data file very likely has spaces instead of tabs.  By default, non SAS-name characters in the header row are replaced with underscore character (_).  The spaces, not being a name character nor a delimiter are converted to underscore (_)

 

The underscores in the EFI computed column

Name_____Gender___Age
12345678901234567890123

indicates what I surmise as @happy_sas_kitty using a text editor configured with a tab stop setting of 3, and the editor replacing tabs with spaces upon File/Save.

ballardw
Super User

If your source data is not sensitive the copy a few lines from the file and paste into a code box opened with the </> icon.

 

If you "value" looks like

"some name  female 23"

all within a single set of quotes then the DSD option will not separate values

 

Since the generated variable name, instead of a more typical 3, then that makes a quote related issue possible.

Do you get just part of the name or do all three values appear in the variable?

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 944 views
  • 3 likes
  • 4 in conversation