BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
DerekD_WF
Obsidian | Level 7

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;
1 ACCEPTED SOLUTION
8 REPLIES 8
Patrick
Opal | Level 21

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;

Patrick_0-1697242070615.png

 

 

DerekD_WF
Obsidian | Level 7

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. 

 PRODFILE.jpg

Patrick
Opal | Level 21

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.

DerekD_WF
Obsidian | Level 7
Thanks - I can open the file in Notepad++ and my pipe-delimited contents look as expected so I think I can safely ignore what the file explorer is interpreting as the filetype.
Amir
PROC Star

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.

 

Amir_1-1697281265625.png

 

 

Thanks & kind regards,

Amir.

Tom
Super User Tom
Super User

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.

Quentin
Super User

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.

BASUG is hosting free webinars Next up: Mark Keintz presenting History Carried Forward, Future Carried Back: Mixing Time Series of Differing Frequencies on May 8. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 1659 views
  • 8 likes
  • 6 in conversation