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

Re: What statement in the SAS University Edition editor will read and print a sas7bdat file?

 

 

I am an entirely brand new learner on the SAS University Edition product.

 

I have successfully written code in the code editor that reads and prints csv and text files (using INFILE/INPUT statements).

 

However, my installation of this edition received various sas7bdat data files. I have a file (data.sas7bdata), which I have opened and read the data with the console's text reader. However, my code statements in the editor do not successfully read and print the data in the sas7bdata file. I did create a dataset, and the file's columns appear in the WORK library, but I receive errors saying "invalid data" in all my run logs, and no data is returned in the results tab. I also tried INFORMAT, but it also has not worked.

 

What code statements does the SAS editor recognize to read and print an sas7bdat file?

 

Thank you very much in advance for your consideration.

 

CODE1:

DATA fileinput2;
INFILE '/folders/myfolders/Module3/somedata.sas7bdat';
INPUT @1 ID 8.
 @2 GP $8.
 @3 AGE 8.
 @4 TIME1 8.
 @5 TIME2 8.
 @6 TIME3 8.
 @7 TIME4 8.
 @8 STATUS 8.
 @9 SEX 8.
 @10 GENDER $6.;
RUN;
QUIT;

 

 

CODE2:

DATA fileinput2;

INFILE '/folders/myfolders/Module3/somedata.sas7bdat';
INPUT ID 1-8
 GP $ 9-16
 AGE 17-24
 TIME1 25-32
 TIME2 33-40
 TIME3 41-48
 TIME4 49-56
 STATUS 57-64
 SEX 65-72
 GENDER $ 73-78;
RUN;

 

 

Errors:

 "NOTE: The infile '/folders/myfolders/Module3/somedata.sas7bdat' is:
       Filename=/folders/myfolders/Module3/somedata.sas7bdat,

       Owner Name=root,Group Name=vboxsf,

       Access Permission=-rwxrwx---,

       Last Modified=01Jun2018:08:13:14,

       File Size (bytes)=9216

 NOTE: Invalid data for ID in line 1 1-87.

 NOTE: Invalid data for AGE in line 1 157-160.

 NOTE: Invalid data for TIME1 in line 1 165-201.

 NOTE: Invalid data for TIME2 in line 1 203-1048.

 NOTE: Invalid data for TIME3 in line 1 1050-1477.

 NOTE: Invalid data for TIME4 in line 1 1480-1621.

 NOTE: Invalid data for STATUS in line 1 1624-1765.

 NOTE: Invalid data for SEX in line 1 1768-1837."

 

 

Run Log attached.

 

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

You can't/don't have to input already existing sas datasets. Rather than the code you tried, just use something like:

libname thedata '/folders/myfolders/Module3';
data fileinput2;
  set thedata.somedata;
run;

or, to print that data,

libname thedata '/folders/myfolders/Module3';
proc print data=thedata.somedata;
run;

Art, CEO, AnalystFinder.com

 

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

You can't/don't have to input already existing sas datasets. Rather than the code you tried, just use something like:

libname thedata '/folders/myfolders/Module3';
data fileinput2;
  set thedata.somedata;
run;

or, to print that data,

libname thedata '/folders/myfolders/Module3';
proc print data=thedata.somedata;
run;

Art, CEO, AnalystFinder.com

 

Reeza
Super User

There are video tutorials and others available here:

http://video.sas.com/detail/videos/sas-analytics-u/video/4572997794001/accessing-data-in-sas-librari...

 

This specific video shows how to use SAS data in libraries which is your question. 

HigherPurp0se
Fluorite | Level 6

Thank you, Reeza. I will study it. Blessings.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1067 views
  • 0 likes
  • 3 in conversation