data outfile.thisfile_curday.; set output.thisfile run; proc export data=outfile.thisfile_curday. outfile="outfile.thisfile_curday..txt" dbms = dlm; delimiter="|"; run;
Respectfully,
blue
You could derive the physical path of the SAS library with the pathname() function.
data outfile.&thisfile_curday.;
set output.thisfile;
run;
proc export data=outfile.&thisfile_curday.;
outfile="%sysfunc(pathname(outfile))\&thisfile_curday..txt"
dbms = dlm;
delimiter="|";
run;
Hello team,
This syntax doesn't create any response.
Regards,
blue & blue
And your question exactly is what?
Since you did not provide an explicit path for the output text file it likely attempted to be placed in the directory SAS considers active. Depending on your SAS configuration that could mean it attempted to write to folder you don't have access to on a server or just someplace you did not look.
ALWAYS specify a complete path for output. Start with a drive letter or mount point and provide the complete path to the folder you want.
WHAT did you log show? Did you look? Did you read the ERROR.
Your first data step creates an error because you have a period as part of the file name:
data outfile.thisfile_curday.;
That is not legal syntax and no data set would be created.
Then Proc Export would report the same illegal name
139 proc export data=outfile.thisfile_curday. ERROR: "OUTFILE.THISFILE_CURDAY." is not a valid name. 140 outfile="outfile.thisfile_curday..txt" ERROR: Invalid data set name outfile.thisfile_curday.outfile. 140 outfile="outfile.thisfile_curday..txt" - 22 ERROR 22-322: Syntax error, expecting one of the following: DATA, DBMS, FILE, OUTFILE, OUTTABLE, TABLE. 140 outfile="outfile.thisfile_curday..txt" - 76 ERROR 76-322: Syntax error, statement will be ignored. NO
So I would say that was a lot of "response".
IF you correct the data set name problem to something valid the log will show you , besides data step code to accomplish the same thing, the location of the file if created. Using the SASHELP.CLASS data set as source for the export:
144 proc export data=sashelp.class 145 outfile="outfile.thisfile_curday..txt" 146 dbms = dlm; 147 delimiter="|"; 148 run; 149 /********************************************************************** 150 * PRODUCT: SAS 151 * VERSION: 9.4 152 * CREATOR: External File Interface 153 * DATE: 25MAR23 154 * DESC: Generated SAS Datastep Code 155 * TEMPLATE SOURCE: (None Specified.) 156 ***********************************************************************/ 157 data _null_; 158 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ 159 %let _EFIREC_ = 0; /* clear export record count macro variable */ 160 file 'outfile.thisfile_curday..txt' delimiter='|' DSD DROPOVER lrecl=32767; 161 if _n_ = 1 then /* write column names or labels */ 162 do; 163 put 164 "Name" 165 '|' 166 "Sex" 167 '|' 168 "Age" 169 '|' 170 "Height" 171 '|' 172 "Weight" 173 ; 174 end; 175 set SASHELP.CLASS end=EFIEOD; 176 format Name $8. ; 177 format Sex $1. ; 178 format Age best12. ; 179 format Height best12. ; 180 format Weight best12. ; 181 do; 182 EFIOUT + 1; 183 put Name $ @; 184 put Sex $ @; 185 put Age @; 186 put Height @; 187 put Weight ; 188 ; 189 end; 190 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */ 191 if EFIEOD then call symputx('_EFIREC_',EFIOUT); 192 run; NOTE: The file 'outfile.thisfile_curday..txt' is: Filename=C:\Users\Owner\outfile.thisfile_curday..txt, RECFM=V,LRECL=32767,File Size (bytes)=0, Last Modified=26Mar2023:13:31:02, Create Time=26Mar2023:13:31:02
The note after the execution shows where the output file was created on my system. Your path will start else where.
Thanks for responses:
data outfile.thisfile_curday.;
in reality it is &curday.; it is a macro variable
I don’t know what the path is, it is on sas a remote location. It doesn’t start with a letter. That is why I pointed out to a direction introduced by a libname.
thanks for your response.
respectfully,
blue
The OUTFILE= option requires a physical path in the file system.
A library reference points to a physical path, but you cannot use it as part of a physical path.
Use your home directory on the server; if your server runs on UNIX (ask your SAS administrators), do this:
proc export
data=outfile.thisfile_&curday.
outfile="~/thisfile_&curday..txt"
dbms=dlm
;
delimiter="|";
run;
There is an error on the line marked in green, can you see what the error is and fix it?
There is an error on the line marked in red, can you see what the error is and fix it?
data outfile.thisfile_curday.; set output.thisfile run;
Hello, thanks a lot for your response!
I added a semicolon to it.
thanks for it!!!
blue blue
You could derive the physical path of the SAS library with the pathname() function.
data outfile.&thisfile_curday.;
set output.thisfile;
run;
proc export data=outfile.&thisfile_curday.;
outfile="%sysfunc(pathname(outfile))\&thisfile_curday..txt"
dbms = dlm;
delimiter="|";
run;
Mind that it is not recommended to clutter up SAS libraries with non-SAS files. It is also quite hard (and usually impossible) to find such files in the Files folder of Enterprise Guide.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.