BookmarkSubscribeRSS Feed
thenewlearner
Calcite | Level 5

Hi,

 

I'm new to SAS and was doing the practice in the SAS Base cert prep guide disc.  trying to write values to raw data file (in chapter 5) and got these errors.

 

 
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data _null_;
63 set sasuser.stress2;
64 file 'stresdat';
65 put id 1-4 name $ 6-25 resthr 27-28 maxhr 30-32 rechr 34-36 timemin 38-39 timesec 41-42 tolerance 44;
66 run;

ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/stresdat.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds


67
68 proc print data=work.stresdat;
ERROR: File WORK.STRESDAT.DATA does not exist.
69 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

70
71
72 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
85  

 

i tried to specify a folder path like it suggested in a different post, fixed the first problem, successfully wrote the file into the folder. not very sure how the virtual machine works with windows but i checked the folder in my machine, it was created the moment i ran the first part of the code. (so the file is created into the folder i specified.) but the second error still occurs. 

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data _null_;
63 set sasuser.stress2;
64 file '/folders/myfolders/certprep/stresdat';
65 put id 1-4 name $ 6-25 resthr 27-28 maxhr 30-32 rechr 34-36 timemin 38-39 timesec 41-42 tolerance 44;
66 run;

NOTE: The file '/folders/myfolders/certprep/stresdat' is:
Filename=/folders/myfolders/certprep/stresdat,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=02May2017:14:18:33

NOTE: 21 records were written to the file '/folders/myfolders/certprep/stresdat'.
The minimum record length was 44.
The maximum record length was 44.
NOTE: There were 21 observations read from the data set SASUSER.STRESS2.
NOTE: DATA statement used (Total process time):
real time 0.08 seconds
cpu time 0.01 seconds


67
68 proc print data=work.stresdat;
ERROR: File WORK.STRESDAT.DATA does not exist.
69 run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

70
71
72 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
85

 

Your help will be greatly appreciated! Thanks.

4 REPLIES 4
Kurt_Bremser
Super User

Several issues here.

 

A file is not a dataset. When you use the file statement in a data step, you address an external file (text), where you write sequential data with the put statement. Such a file will not be recognized by SAS as a dataset (unless you engage in VERY complicated programming and create a SAS dataset manually; don't waste your time with that). To create a dataset in library work, use

data work.stresdat;

Keep in mind that library work is transient and will be deleted when your SAS session terminates. If you want to keep datasets, put them in another library (a folder in myfolders, with according libname statement).

You cannot use proc print on a file created with the file and put statements from a data step. proc print can only use SAS datasets as input.

 

Your initial error

ERROR: Insufficient authorization to access /opt/sasinside/SASConfig/Lev1/SASApp/stresdat.

was caused by you not using a UNIX absolute path (starting at the root directory, therefore with a forward slash) for the external file, so SAS tried to put it into the current working directory of the SAS process (the direcory where SAS was started), where you do not have write permissions.

thenewlearner
Calcite | Level 5

Googled _null_ while waiting for a reply, plus your explanation, Now I understand. Very interesting and thank you very much for answering such a newbie question. Cheers :).

Kurt_Bremser
Super User
data _null_;

is a means to have access to the power of the data step without creating a new dataset (what the data step was initially designed for). It is used to write external files, make a quick calculation (eg first day of month 3 months before now), or any other task where the use of datastep functions & statements is handy.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 6321 views
  • 0 likes
  • 2 in conversation