BookmarkSubscribeRSS Feed
Tommac72584
Fluorite | Level 6

Here is the code that I am using.

 

ods graphics on;
options ls=80 ps=50 nodate pageno=1;
Data HBAT;

Infile '/home/tmaciver7840/my_content/hbat tabs.txt' DLM = '09'X TRUNCOVER;

Input ID X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 X11 X12 X13 X14 X15 X16 X17 X18 X19

X20 X21 X22 X23;

 

The output data just shows the columns and there is nothing in the results. I don't see the actual data (screenshots attached). Where am I going wrong here? Thanks


Screen Shot 2016-06-24 at 12.51.55 PM.pngScreen Shot 2016-06-24 at 12.51.24 PM.pngScreen Shot 2016-06-24 at 12.51.19 PM.pngScreen Shot 2016-06-24 at 12.51.05 PM.png
3 REPLIES 3
Tommac72584
Fluorite | Level 6
I'm hearing I need a library set up? Is this true?
ballardw
Super User

If you don't specify a library then the default would be to assign the data to the WORK library. The Work library contents are deleted when you close the session. So if you want the data available without re-reading the file then it is best to create a permanent library

 

You have errors but you do not show the part of the log that would show the actual text of the errors. The bit displayed in the first PNG is typical when you specify a delimiter or other options in the INFILE incorrectly. Note that the  second block of data starting with 71 (which indicates the position in the data line) has X23.1.2.0.1 etc. and then just continues to 141 (and I'm guessing there are further lines),

 

First that indicates that SAS attempted to read the values of X1 X2 etc for the numeric variables X1. You likely wanted to have the option FirstObs=2 on the INFILE statement to skip what is likely a header row in the input file.

There may also be an issue with the end of line character of the dataset being other than the program expects (or completely missing). You may need to use the TERMSTR= option on the Infile statement, Possibly TERMSTR=CR if the file originated on a Mac. If the original file was PC then TERMSTR=CRLF may be needed, TERMSTR=LF for Unix.

Tom
Super User Tom
Super User

I always wonder why people post photographs of their log?  Isn't it easier to copy and paste the TEXT from the log rather than taking a picture of it and trying to figure out how to get this web site to accept the picture?

 

Anyway the first picture shows your error.

First you are trying the read the header row as data and second SAS is not seeing the end of line.  You aslo probably want to add the DSD option to make sure it handles missing values properly.

 

infile '/home/tmaciver7840/my_content/hbat tabs.txt'
  DSD DLM = '09'X TRUNCOVER 
  FIRSTOBS=2 TERMSTR=CR 
;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1137 views
  • 0 likes
  • 3 in conversation