Greetings All, I am working through the "User’s Guide Customizing the Kaplan-Meier Survival Plot" text and trying to run the code to establish macros. The code below was taken straight from the text. When I run the code, I get an error: "Insufficient authorization to access C:\Windows\system32\macros.tmp." and I cannot figure out how to resolve it. Any and all advice is welcome.
Thanks
Bill (novice, but learning SAS user)
data _null_;
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/131;
infile "http:&url/templft.html" device=url;
file 'macros.tmp';
retain pre 0;
input;
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;
%inc 'macros.tmp' / nosource;
Place the full path of the folder you would like to have the output on the FILE statement. If you do not then you are defaulting to the drive where SAS is executing from, in this case the system folder, which is very likely locked down against casual writing.
You file statement should look more like:
File "C:\somefolder\output\macros.tmp";
Your %include would have to have the same path referenced.
It is a "best practice" to always place full paths from a drive (windows) or mount point in other file system.
Yes, that worked. Thank you so much.
The error message relates to next line:
%inc 'macros.tmp' / nosource;
%INC stands for %include, that's to load a code file, in this case
load file 'macros.tmp' from a default root, resulted as C:\Windows\system32\macros.tmp.
This file probably holds macro programs code and need be included for compilation before use.
Look at the documentation, where from to download it to your PC and adapt the path
to this file, as in:
%include "<path to file>/macros.tmp"; /* use either single or double quotes */
Yes, that was the problem. Thanks so much for the quick reply.
For such temporary storage (as it seems to be needed only for downloading and then including the code), one can always use a temporary file reference:
%let url = //support.sas.com/documentation/onlinedoc/stat/ex_code/131;
filename macrotmp temp;
data _null_;
infile "http:&url/templft.html" device=url;
file macrotmp;
retain pre 0;
input;
if index(_infile_, '</pre>') then pre = 0;
if pre then put _infile_;
if index(_infile_, '<pre>') then pre = 1;
run;
options source2;
%inc macrotmp;
I set options source2 to verify that the code was actually loaded.
Thank you so much.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: