I am preparing for the SAS 9.4 Base Programming Performance-Based Exam and while trying to solve the practice exam using the data given here: https://support.sas.com/downloads/package.htm?pid=2339. After third program submitted the system gave me error;
"User <username> has insufficient permissions to create /home/<username>/.. Contact your system administrator to resolve.
"
My username at right below corner switched from "u0*******" to my e-mail address and when I reload the homepage my quota usage increased from 518 MB to 5618 MB. I checked properties of the new files that I uploaded and also outputs I created but all of them was under 1 MB in size. When I deleted them all, the quota reversed back. In the end, I could not complete the practice exam. I am posting the 3 practice program that I have submitted before the error.
libname cert "/home/u43396434/Cert/input";
libname results "/home/u43396434/Cert/output";
data results.output04;
set cert.input04;
INT1=round(VAR1);
INT2=round(VAR2);
VAR3=round(VAR1) * round(VAR2);
VAR20=sum(of VAR12-VAR19);
run;
proc print data=results.output04;
run;
proc sort data=cert.input08a out=sorteda;
by ID;
run;
proc sort data=cert.input08b out=sortedb;
by ID;
run;
data results.match08 results.nomatch08 (drop=Ex:);
merge sorteda (in = up1) sortedb (in = up2);
by ID;
if up1 = 1 and up2 = 1 then output results.match08;
else output results.nomatch08;
run;
proc print data= results.nomatch08;
run;
data results.output12;
set cert.input12;
do until (salary>500000);
salary=salary*0.0565;
year+1;
output;
end;
run;
proc print data=results.output12;
run;
You did not see the dataset because it's creation failed, but it is quite obvious why you overran your quota:
data results.output12;
set cert.input12;
do until (salary>500000);
salary=salary*0.0565;
year+1;
output;
end;
run;
The starting salary is about 250000, but your formula decreases the value, so you will never reach the condition for terminating.
If you want to do an increase by percentage, you need to add 1:
data results.output12;
set cert.input12;
do until (salary > 500000);
salary = salary * (1 + 0.0565);
year + 1;
output;
end;
run;
Also note how a little indentation and use of whitespace makes code readable.
You did not see the dataset because it's creation failed, but it is quite obvious why you overran your quota:
data results.output12;
set cert.input12;
do until (salary>500000);
salary=salary*0.0565;
year+1;
output;
end;
run;
The starting salary is about 250000, but your formula decreases the value, so you will never reach the condition for terminating.
If you want to do an increase by percentage, you need to add 1:
data results.output12;
set cert.input12;
do until (salary > 500000);
salary = salary * (1 + 0.0565);
year + 1;
output;
end;
run;
Also note how a little indentation and use of whitespace makes code readable.
Thank you for the helpful answer. Still, it is quite amazing how a wrong loop logic fills up 5GB of data in less than 10 seconds.
The spacing and indentation was good but lost on the forum posting.
You're talking SAS here, not some Micro-crap like Excel. Just to give you a perspective, I added a "safety valve" to your code, and ran it on my University Edition on a MacBook Pro:
78 do until (salary>500000 or year > 1000000); 79 salary=salary*0.0565; 80 year+1; 81 output; 82 end; 83 run; NOTE: There were 1 observations read from the data set CERT.INPUT12. NOTE: The data set RESULTS.OUTPUT12 has 997986 observations and 2 variables. NOTE: Verwendet wurde: DATA statement - (Gesamtverarbeitungszeit): real time 0.24 seconds cpu time 0.10 seconds
So you can see that it took only a quarter of a second to write a million records (filesize: 16MB) on a notebook. In a second, it would have been at 64 MB, in 10 seconds at 640 MB or even more. On a notebook.
Now think of a dedicated server with premium storage at the backend, and server-grade CPUs.
That's why prudent server admins ALWAYS have quota restrictions set for end users on servers. One careless typo can cause a showstopper for everyone else (if you fill /home or the WORK location, nobody can start a SAS session).
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.