BookmarkSubscribeRSS Feed
wbaker0621
Fluorite | Level 6

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;
6 REPLIES 6
ballardw
Super User

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.

wbaker0621
Fluorite | Level 6

Yes, that worked. Thank you so much.

Shmuel
Garnet | Level 18

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 */

 

wbaker0621
Fluorite | Level 6

Yes, that was the problem. Thanks so much for the quick reply.

Kurt_Bremser
Super User

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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 2928 views
  • 1 like
  • 4 in conversation