I am a new SAS user, I have been trying to enter some values into one output file. But I keep getting the error
ERROR: Physical file does not exist
In fact I even copied the location of the work folder and created a txt file there, still I get the same error.
Please pour in suggestions
We cannot help if you do not show us the code.
Use the Insert Code icon (looks like < / > ) to get a pop-up window where you can paste the lines from the SAS log that shows how you are trying to READ from the file.
proc import datafile='X:\Files\Users\XXXX\SAS\Sample.txt' out=Inputs dbms=dlm replace; delimiter='09'x; run; proc print data=Work.Inputs; run; %sysfunc(pathname(work))\Inputs.txt %sysfunc(fexist(pathname(work)))\Output.txt);
I tried to take data from a tab delimited text file. trying to read/ create input and output txt file in work folder.This is where I get the error. The output data returns the input from the above code, but gives this error for output
ERROR: Physical file does not exist, F:\SASWORK\_TD25664_VIRTAPP-PVSC49_\Prc2\Output.txt.
Please post the complete (all code and messages) log of the PROC IMPORT step.
Actually I am not getting a problem/error in Proc IMport step.
after that I use a %tslit command
Since for confidential purpose, I cant share which file I am using but the complete structure is as follows
proc import datafile='X:\Files\Users\60135553\SAS\Sample.txt' out=Inputs dbms=dlm replace; delimiter='09'x; run; proc print data=Work.Inputs; run;
followed by
x %tslit("Location.exe" location.grm %sysfunc(pathname(work))\Inputs.txt %sysfunc(pathname(work))\Output.txt); data dd_xx; length Primary_Key $36 phn_name $50 phn_code $6 gifFlags $20; infile "%sysfunc(pathname(work))\Output.txt" dlm='09'x dsd; input Primary_Key $ sa1_2021_code $ sa1_2016_code $ phn_name $ phn_code $ gifFlags $; run;
Instead of using the X statement, use the FILENAME PIPE method to run external commands:
data _null_;
infile "Location.exe location.grm %sysfunc(pathname(work))\Inputs.txt %sysfunc(pathname(work))\Output.txt 2>&1" pipe;
input;
put _infile_;
run;
You will find all diagnostic messages returned from the command in the SAS log.
That error message is different than the one you posted earlier.
It is saying that it cannot find a file whose name ends in a right parentheses.
If you tried to generate the name using some function call you appear to have an extra ) in your code.
To really tell we need to see the whole log, not just the error message.
And please remember to use the Insert Code button (looks like < / > ) to get a pop-up window were you can paste the text. That way the spacing is not modified by the web page trying to flow the text into paragraphs.
The top of that program looks find. What does the LOG say when you run it?
That last line is gibberish. Why do you have that line? What are your trying to do with it?
Please refer to my code above in the reply
ERROR: Physical file does not exist, F:\SASWORK\_TD28280_VIRTAPP-PVSC49_\Prc2\Output.txt.
I get this in the log
We can't know what below highlighted bits are supposed to do and if this is even valid syntax.
The log tells you that ....\Output.txt doesn't exist. Based on the code you share you appear to believe the x command creates the file but then SAS clearly tells you that this is not the case.
May-be run your command first via a command prompt on some file in a permanent location and make sure this works.
Open Windows explorer.
Navigate to F:\SASWORK\_TD28280_VIRTAPP-PVSC49_\Prc2
Show a screen capture of the files in that folder.
If you want make a temporary file then use the TEMP engine in a FILENAME statement.
filename output temp;
proc export data=sashelp.class dbms=csv file=output ;
run;
If there is some reason that you need to give a special name to the temporary file than you can get the location of the WORK directory using %SYSFUNC(PATHNAME(WORK)).
filename output "%sysfunc(pathname(work))/output.txt";
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.