☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-27-2022 12:35 AM
(1279 views)
I am trying to create export macro in SAS Enterprise Guide 8.3 version
I got error--- ERROR: Insufficient authorization to access C:\WINDOWS\system32\&file.
when using the macro
my code is as below
%macro export(dset,file);
proc export data=&dset
outfile='&file'
dbms=csv
replace;
run;
%mend;
%export (sashelp.cars,C:\Users\shree\Desktop\SAS LIb\cars.csv);
1 The SAS System 10:59 Tuesday, December 27, 2022 1 ;*';*";*/;quit;run; 2 OPTIONS PAGENO=MIN; 3 %LET _CLIENTTASKLABEL='Program'; 4 %LET _CLIENTPROCESSFLOWNAME='Standalone Not In Project'; 5 %LET _CLIENTPROJECTPATH=''; 6 %LET _CLIENTPROJECTPATHHOST=''; 7 %LET _CLIENTPROJECTNAME=''; 8 %LET _SASPROGRAMFILE=''; 9 %LET _SASPROGRAMFILEHOST=''; 10 11 ODS _ALL_ CLOSE; 12 OPTIONS DEV=SVG; 13 GOPTIONS XPIXELS=0 YPIXELS=0; 14 %macro HTML5AccessibleGraphSupported; 15 %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) >= 0 %then ACCESSIBLE_GRAPH; 16 %mend; 17 ODS LISTING GPATH=&sasworklocation; 18 FILENAME EGHTML TEMP; 19 ODS HTML5(ID=EGHTML) FILE=EGHTML 20 OPTIONS(BITMAP_MODE='INLINE') 21 %HTML5AccessibleGraphSupported 22 ENCODING='utf-8' 23 STYLE=HTMLBlue 24 NOGTITLE 25 NOGFOOTNOTE 26 GPATH=&sasworklocation 27 ; NOTE: Writing HTML5(EGHTML) Body file: EGHTML 28 29 %macro export(dset,file); 30 proc export data=&dset 31 outfile='&file' 32 dbms=csv 33 replace; 34 run; 35 %mend; 36 37 38 %export (sashelp.cars,C:\Users\shree\Desktop\SAS LIb\cars.csv); 39 /********************************************************************** 40 * PRODUCT: SAS 41 * VERSION: 9.4 42 * CREATOR: External File Interface 43 * DATE: 27DEC22 44 * DESC: Generated SAS Datastep Code 45 * TEMPLATE SOURCE: (None Specified.) 46 ***********************************************************************/ 47 data _null_; 48 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ 49 %let _EFIREC_ = 0; /* clear export record count macro variable */ 50 file '&file' delimiter=',' DSD DROPOVER lrecl=32767; 51 if _n_ = 1 then /* write column names or labels */ 52 do; 53 put 54 "Make" 55 ',' 56 "Model" 2 The SAS System 10:59 Tuesday, December 27, 2022 57 ',' 58 "Type" 59 ',' 60 "Origin" 61 ',' 62 "DriveTrain" 63 ',' 64 "MSRP" 65 ',' 66 "Invoice" 67 ',' 68 "EngineSize" 69 ',' 70 "Cylinders" 71 ',' 72 "Horsepower" 73 ',' 74 "MPG_City" 75 ',' 76 "MPG_Highway" 77 ',' 78 "Weight" 79 ',' 80 "Wheelbase" 81 ',' 82 "Length" 83 ; 84 end; 85 set SASHELP.CARS end=EFIEOD; 86 format Make $13. ; 87 format Model $40. ; 88 format Type $8. ; 89 format Origin $6. ; 90 format DriveTrain $5. ; 91 format MSRP dollar8. ; 92 format Invoice dollar8. ; 93 format EngineSize best12. ; 94 format Cylinders best12. ; 95 format Horsepower best12. ; 96 format MPG_City best12. ; 97 format MPG_Highway best12. ; 98 format Weight best12. ; 99 format Wheelbase best12. ; 100 format Length best12. ; 101 do; 102 EFIOUT + 1; 103 put Make $ @; 104 put Model $ @; 105 put Type $ @; 106 put Origin $ @; 107 put DriveTrain $ @; 108 put MSRP @; 109 put Invoice @; 110 put EngineSize @; 111 put Cylinders @; 112 put Horsepower @; 113 put MPG_City @; 114 put MPG_Highway @; 3 The SAS System 10:59 Tuesday, December 27, 2022 115 put Weight @; 116 put Wheelbase @; 117 put Length ; 118 ; 119 end; 120 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ 121 if EFIEOD then call symputx('_EFIREC_',EFIOUT); 122 run; ERROR: Insufficient authorization to access C:\WINDOWS\system32\&file. NOTE: The SAS System stopped processing this step because of errors. NOTE: There were 1 observations read from the data set SASHELP.CARS. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 0 records created in &file from SASHELP.CARS. NOTE: "&file" file was successfully created. NOTE: PROCEDURE EXPORT used (Total process time): real time 0.10 seconds cpu time 0.10 seconds 123 124 %LET _CLIENTTASKLABEL=; 125 %LET _CLIENTPROCESSFLOWNAME=; 126 %LET _CLIENTPROJECTPATH=; 127 %LET _CLIENTPROJECTPATHHOST=; 128 %LET _CLIENTPROJECTNAME=; 129 %LET _SASPROGRAMFILE=; 130 %LET _SASPROGRAMFILEHOST=; 131 132 ;*';*";*/;quit;run; 133 ODS _ALL_ CLOSE; 134 135 136 QUIT; RUN; 137
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I edited your question so that the log is posted in proper manner.
In the FILE statement, use double quotes; macro triggers (& and %) are not resolved inside single quotes.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I edited your question so that the log is posted in proper manner.
In the FILE statement, use double quotes; macro triggers (& and %) are not resolved inside single quotes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks so much it works