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

When working through the Statistics 1, demo, I received the above error message. Following are the data steps statements:

I am using the sas practice files.

 

libname statdata '/folders/myfolders/ECST131';

data statdata.testscores;
infile "/folders/myfolders/ECST131/testscores.sas7bdat";
input Gender SATScore IDNumber;
run;

 

I tried several changes but the problem is persistent. I tried to look up in other support forums and communities and tried solutions provided but the error is still there. I got the results after doing the PROC PRINT statement. 

 

Please advise if I am missing or not doing something basic. I am using SAS Studio 3.5

 

Thank you, I appreciate it.

 

Murali Sastry

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

What are you attempting to do? That does not look like anything that would come from the demo training.

 

The line of code;

 

data statdata.testscores

says to create a data set named in statdata.

 

This line

infile "/folders/myfolders/ECST131/testscores.sas7bdat";

indicates that there is already a SAS dataset named Testscores in the STATDATA library as the path is the same as the .

 

The file is locked by SAS because the first line is making sure no process interrupts the activity you want.

 

You can access that EXISTING data set as statdate.testscores.

You could create copy or new data set using the SET, to bring in data from a SAS data set instead of INFILE which is to read external files.

 

Also try executing the code

 

data work.junk;

infile "/folders/myfolders/ECST131/testscores.sas7bdat";
input Gender SATScore IDNumber;
run;

which you may think would create a data set in the WORK library named junk.

Errors result because of assumptions about INFILE when nothing except a file name is provided. Namely that it is a text file and the Input statement expects to find blanks between the values to read. The SAS7BDAT is a binary file.

 

Try this instead:

 

data statdata.testscoresTemp;

   set statdata.testcores;

   keep gender SATScore IDNumber;

run;

proc print data=statdata.testscoresTemp;

run;

View solution in original post

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, the error message really tells you the problem.  The file testscores.sas7bdat is process locked by the system.  Do you have that file open in SAS?  Do you have it open in any other application, does someone else have it opened?  

What happens is when SAS opens a file it gets locked so that file can't be written to whilst its open.  Close the file form where ever you have it open.  You can try starting a new session, then run the code, make sure the steps you execute have completed sucessfully and you should be fine.

ballardw
Super User

What are you attempting to do? That does not look like anything that would come from the demo training.

 

The line of code;

 

data statdata.testscores

says to create a data set named in statdata.

 

This line

infile "/folders/myfolders/ECST131/testscores.sas7bdat";

indicates that there is already a SAS dataset named Testscores in the STATDATA library as the path is the same as the .

 

The file is locked by SAS because the first line is making sure no process interrupts the activity you want.

 

You can access that EXISTING data set as statdate.testscores.

You could create copy or new data set using the SET, to bring in data from a SAS data set instead of INFILE which is to read external files.

 

Also try executing the code

 

data work.junk;

infile "/folders/myfolders/ECST131/testscores.sas7bdat";
input Gender SATScore IDNumber;
run;

which you may think would create a data set in the WORK library named junk.

Errors result because of assumptions about INFILE when nothing except a file name is provided. Namely that it is a text file and the Input statement expects to find blanks between the values to read. The SAS7BDAT is a binary file.

 

Try this instead:

 

data statdata.testscoresTemp;

   set statdata.testcores;

   keep gender SATScore IDNumber;

run;

proc print data=statdata.testscoresTemp;

run;

Murali11
Obsidian | Level 7

Hello ballardw:

 

Your solution worked. Thank you very much. I appreciate it.

 

 

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
  • 3 replies
  • 3671 views
  • 1 like
  • 3 in conversation