BookmarkSubscribeRSS Feed
jc3992
Pyrite | Level 9

Hello everyone,

 

I was using the import method trying to read in a tab-delimited file,

but failed.

I have been trying this for quite a while,

hope to get nay insights.

 

The code is as below:

 

DATA ob1;
INFILE "&dirdata.SAS_Test/illumination.txt" DLM='09'x DSD truncover;
INPUT mag sodium strontium numcandle;
RUN;

PROC PRINT DATA=ob1;
RUN;

The original file is as the attached.

 

Any helps would be highly appreciated.

Thanks!

 

 

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

From the looks of it, I think your problem is the .SASTEST part of your path. Try

 

DATA ob1;
INFILE "&dirdata/illumination.txt" DLM='09'x DSD truncover;
INPUT mag sodium strontium numcandle;
RUN;
andreas_lds
Jade | Level 19

@jc3992 wrote:

Hello everyone,

 

I was using the import method trying to read in a tab-delimited file, but failed.

 


What does "failed" mean? The file was not read? The file was partly meeting your expectations? The computer exploded?

If there is an error in the log, posting the log will make it easier for us to suggest something helping you to solve the problem. Logs are best posted by using the box opened by the {i}-icon .

ballardw
Super User

@jc3992 wrote:

Hello everyone,

 

I was using the import method trying to read in a tab-delimited file,

but failed.

I have been trying this for quite a while,

hope to get nay insights.

 

The code is as below:

 

DATA ob1;
INFILE "&dirdata.SAS_Test/illumination.txt" DLM='09'x DSD truncover;
INPUT mag sodium strontium numcandle;
RUN;

PROC PRINT DATA=ob1;
RUN;

The original file is as the attached.

 

Any helps would be highly appreciated.

Thanks!

 

 


"Failed" is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

jc3992
Pyrite | Level 9

Thank you all very much for all the helps.

 

My modified code is as below, using directly input.

And the LOG did not throw any error,

but there were a few missing data in the output.

Any suggestions would be highly appreciated.

 

Data illumination6;
input x1 1-3 x2 7.  x3 7. Y 18-21;
datalines;
0.4	0.1	     0.47	        75
0.4	0.1	     0.42	        180
0.6	0.1	     0.27	        195
0.6	0.1	     0.27	        195
0.6	0.1	     0.22	        300
0.4	0.47         0.1	        145
0.4	0.42         0.1	        230
0.6	0.27         0.1	        220
0.6	0.22         0.1	        350
0.5	0.1	     0.345	        220
0.5	0.345	     0.1	        260
0.4	0.2725	     0.2725	        190
0.6	0.1725	     0.1725	        310
0.5	0.235	     0.235	        260
0.5	0.21	     0.21	        410
0.5	0.2225	     0.2225	        425
;
run;
proc print data=illumination6;
run;
SuzanneDorinski
Lapis Lazuli | Level 10

The text file that you posted has some spaces in addition to tabs.  

 

Your code using DATALINES also has a mix of tabs and spaces.  The 75 value for Y in the first record of DATALINES starts in column 29, when the input statement is looking for the Y value in columns 18 through 21.

 

I used Notepad++ to see that the text file and the DATALINES version have a mixture of tabs and spaces.  

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 5 replies
  • 1725 views
  • 2 likes
  • 5 in conversation