Looks like your SAS server is on a Unix/Linux machine and you are trying to save file on your windows desktop./laptop.
Try saving the file into your workspace on the Linux machine. The following code will give the path of your workspace on server. Anything here would disappear once your session closes.
%let temp_path=%sysfunc(pathname(WORK));
%put &=temp_path;
/* save your file to &temp_path./your_file.txt */
You can save your file to the above location
It might look something like the below. Notice the change I made to the FILENAME. The path is brought in via a macro variable.
%let temp_path=%sysfunc(pathname(WORK));
%put &=temp_path;
FILENAME Out_File "&temp_path/my_file.txt" LRECL=46;
Data _NULL_;
Set Have;
File Out_File;
Put @1 ID
@10 First_Name
@35 Middle_Initial
@36 Last_Name
;
RUN;
Jim
Hello @Boswser
1.The pathname(WORK) gives the full path of your work directory/temp space. This is a location on the server and not on desktop.
2.The full path of the work directory is a dynamic value and it changes with your session. Therefore you should only use the macro and not the physical name. Thus you have the following
/* This line extracts or finds the path*/
%let temp_path=%sysfunc(pathname(WORK));
/* when you want the filename use this :"&temp_path/my_file.txt"
for example thanks to @jimbarbour */
FILENAME Out_File "&temp_path/my_file.txt" LRECL=46;
3.Your SAS Server is on Unix and EG on your desktop. Your code executes on the server
Typically desktop locations under your scenario are not accessible to the code running ion the server.
Thus one cannot use desktop/laptops paths like c:\
You should literally code it with the literal WORK. WORK is the libname. SAS will then retrieve the path for you.
%let temp_path=%sysfunc(pathname(WORK));
Jim
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.