Assume that Sasuser.One does not exist and that the following SAS program is submitted at the beginning of a new SAS session:
data sasuser.one; x=1; y=27; output one; run;
You can find out what the result is by running the program. That will give you a quicker answer than by coming here and asking.
Then if you read the log, you can see the problem. Actually, there are two problems shown in the log. You cannot create a data set in library SASUSER, it is locked, it is read-only and nothing can be written to that library. You also have a data step error, the OUTPUT data set (ONE) is not the name of the DATA set you are trying to create (SASUSER.ONE). These two names must be the same.
For example, this works:
data one;
x=1;
y=27;
output one;
run;
Now the output data set is the same as the name of the data set you are creating. This is required.
Even simpler:
data one;
x=1;
y=27;
run;
You don't need to use the OUTPUT command in his situation. There are other situations where OUTPUT is required.
SASUSER in a single machine install is writable and is where the users Profile settings are kept for SAS Display Manager.
It is not a good idea to place user data sets there if writable in your install as update processes may replace the library or its contents.
Not sure I understand what your question is. There is no "output" because the step will not run because of the error.
You can see this when you look at the LOG.
1 data sasuser.one; 2 x=1; 3 y=27; 4 output one; --- 455 ERROR 455-185: Data set was not specified on the DATA statement. 5 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set SASUSER.ONE may be incomplete. When this step was stopped there were 0 observations and 2 variables. WARNING: Data set SASUSER.ONE was not replaced because this step was stopped. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.00 seconds
My log has that extra warning about not replacing the dataset because I already had a dataset with that name from 4 years ago.
I already mentioned that assume that sasuser.one dataset doesn't exist.
the result will be an output dataset work.one with the variables x and y with 0 observations and wanna know why?
No. It will NOT make a dataset named ONE (which normally means WORK.ONE unless have created USER libref or used the USER= option to pick a different libref).
You can confirm by trying to look at the ONE dataset.
7 proc contents data=one; run; ERROR: File WORK.ONE.DATA does not exist. NOTE: Statements not processed because of errors noted above. NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.00 seconds cpu time 0.01 seconds NOTE: The SAS System stopped processing this step because of errors.
If you want it to make ONE then include it in the DATA statement.
Try this step instead :
data one two three;
x=1;
y=27;
output one;
run;
What do you expect to happen?
Will it run?
What dataset(s) will be created?
How many observations?
8 data one two three; 9 x=1; 10 y=27; 11 output one; 12 run; NOTE: The data set WORK.ONE has 1 observations and 2 variables. NOTE: The data set WORK.TWO has 0 observations and 2 variables. NOTE: The data set WORK.THREE has 0 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.02 seconds cpu time 0.00 seconds
@Nipun22 wrote:
I already mentioned that assume that sasuser.one dataset doesn't exist.
...
Whether a data step will compile and run does not depend on whether the datasets listed in the DATA statement exist or not.
The only impact if the dataset exists is that the data step will replace the existing dataset, assuming the step runs successfully.
Note: For nuances on when the dataset is not replaced but instead edited check out the MODIFY statement.
Maxim 4 (short version): Try It.
This happens on SAS On Demand, which is fairly typcal for current client-server setups:
69 data sasuser.one; 70 x=1; 71 y=27; 72 output one; ___ 455 ERROR 455-185: Data set was not specified on the DATA statement. 73 run; ERROR: Schreibzugriff für Member SASUSER.ONE.DATA verweigert. NOTE: The SAS System stopped processing this step because of errors. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit):
You can see that no dataset is created at all.
Now, if we change the target to a location where write permission is given, this happens:
69 data home.one; 70 x=1; 71 y=27; 72 output one; ___ 455 ERROR 455-185: Data set was not specified on the DATA statement. 73 run; NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set HOME.ONE may be incomplete. When this step was stopped there were 0 observations and 2 variables.
On inspection, there is a dataset ONE in library HOME, with two variables and no observations; no observations because no OUTPUT statement for HOME.ONE was given, and the one OUTPUT statement present in the code prevents the default OUTPUT that a DATA step usually does.
this is one of the questions from the sas base practice exam.
How would I understand it then?
same code also showing access denied to the sasuser library in sas studio
Looks like a question from a time way back when SASUSER was writable in most installations. But if SASUSER is writable, answer b is correct for the stated reasons.
@Nipun22 wrote:
sasuser library was writable in earlier times?
Yes. It was on the mainframe where I started working with SAS, and we kept it that way when we migrated to UNIX.
@Nipun22 wrote:
sasuser library was writable in earlier times?
There is a system option for controlling that, RSASUSER, which much be specified at session start.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.