How do I go about creating a text file that does not have the ".txt" extension in the filename? If I remove from the ".txt" from the fileref below, it creates the file as a "PART3 File" for the filetype.
Yes, the naming convention is stupid, but it's in the requirements for how the ingesting system needs the file to be.
options nobomfile ;
filename out '/dir/FILEPART1.PART2.PART3.txt' encoding="utf-8" termstr=crlf ;
proc export data=work.my_data
outfile=qtlout
dbms=dlm
replace;
delimiter="|";
putnames=NO;
run;
What the dumb Windows Explorer thinks about your file is irrelevant. The target software is relevant, as long as it can read the file, all is good.
In your code you define fileref "out" but then use a fileref "qlout" in Proc Export. Not sure if that's the issue.
To my knowledge the file extension is just part of the name of the file without any functional relevance to the code Proc Export creates.
I can't replicate what you describe and things work for me as expected.
options nobomfile ;
filename outfile 'c:\temp\FILEPART1.PART2.PART3.dummy' encoding="utf-8" termstr=crlf ;
proc export
data=sashelp.class
outfile=outfile
dbms=dlm
replace;
delimiter="|";
putnames=NO;
run;
Apologies for the confusion - I was "cleaning" up my code to make it more generic for public sharing and forgot to edit the fileref in both places. I am using the same fileref in both places in my actual code.
Perhaps it doesn't matter how windows is trying to associate the file "type", but below is a screen shot from my windows explorer, bottom file.
I'm not sure what you're trying to tell me here but bottom-line is: SAS will export to a file with a name exactly as you define it in your filename statement.
If that's really not the case for you then please share the actual code AND the full SAS log.
What the dumb Windows Explorer thinks about your file is irrelevant. The target software is relevant, as long as it can read the file, all is good.
Hi,
As you have indicated the value in the Type column in Windows Explorer is based on the file extension - see below screen shot - and when there is no extension then "File" appears in the Type column, as per the screen shot. Perhaps you should clarify what you want or expect to see in the Type column and why.
If the file is named according to the requirements you've been given, then perhaps you should ask the requestors to check if the file is suitable for their requirements and they can let you know if they need anything different.
Thanks & kind regards,
Amir.
What Windows thinks the file extension means does not really matter, other than it is easier when the file extension matches to content since then things like double clicking to open a file will work properly.
If you don't want Windows to treat PART3 as the file extension then either add some other extension or remove the other periods in the filename. Perhaps you could replace the periods with underscores instead.
I think the Windows definition of a file extension is "text in a file name after the last period (full stop)."
So when you name a file:
FILEPART1.PART2.PART3.txt
The extension is txt
If you name a file:
FILEPART1.PART2.PART3
the extension is PART3
But the extension is just a part of the file name on Windows. It doesn't really matter. If you have a period in a file name, there is no way to tell Windows that the text after the period is not an extension.
I find life becomes easier on Windows if you configure it to show extensions for all file names, not hide them, which is the default.
So I agree with everyone else, you've already accomplished your goal.
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.