Learning SAS? Welcome to the exclusive online community for all SAS learners.

How to create a SAS data set from a raw data file in a SAS library?

Reply
Occasional Contributor
Posts: 11

How to create a SAS data set from a raw data file in a SAS library?

I tried to create a SAS data set called 'EXERCISE' from a raw data file 'exer.dat' stored in a user-defined SAS library called 'basecert'.

The following FILENAME statement worked without producing any errors.

FILENAME EXER '/folders/myfolders/basecert/exer.dat';

However, the following DATA step didn't work because an error was produced: ERROR: Physical file does not exist, /folders/myfolders/basecert/exer.dat.

DATA WORK.EXERCISE;

  INFILE EXER;

  INPUT ID $ 1-4 Age 6-7 ActLevel $ 9-12 Sex $ 14;

RUN;

Could anyone let me know why such an error was produced? Thanks.

Super User
Posts: 19,789

Re: How to create a SAS data set from a raw data file in a SAS library?

Does the following work?

Have you set up basecert as a shared folder?

DATA WORK.EXERCISE;

  INFILE '/folders/myfolders/basecert/exer.dat';

  INPUT ID $ 1-4 Age 6-7 ActLevel $ 9-12 Sex $ 14;

RUN;

Occasional Contributor
Posts: 11

Re: How to create a SAS data set from a raw data file in a SAS library?

Thank you again Reeza. I was actually able to figure out what the problem was. The file 'exer.dat' was saved under 'myfolders' and not 'basecert' in SAS Studio. I changed the physical location, and the data step worked fine. I have another question though:

How come the following statement, FILENAME EXER '/folders/myfolders/basecert/exer.dat'; didn't produce an error when the file 'exer.dat' was never in the 'basecert'

folder (the 'basecert' folder was empty at that time). Please let me know if you have the answer. Thanks.


Super User
Posts: 11,343

Re: How to create a SAS data set from a raw data file in a SAS library?

Filename statement can also be used to create an output file. So as long as the folder exists SAS is prepared to create the file in it.

Ask a Question
Discussion stats
  • 3 replies
  • 338 views
  • 4 likes
  • 3 in conversation