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.
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
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
Thank you.
There are video tutorials and others available here:
This specific video shows how to use SAS data in libraries which is your question.
Thank you, Reeza. I will study it. Blessings.
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’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.
Ready to level-up your skills? Choose your own adventure.