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

Hello SAS Users! I am using a proc export step to export a txt file; however, the output keeps exporting without the ".txt" file extension. 

 

PROC EXPORT DATA= survey
OUTFILE= "\\fakepath\survey_&today.txt"
DBMS= tab
REPLACE;
PUTNAMES=YES;
RUN ;

 

Output file looks like this: "survey_22May2020" without the ".txt" extension. So I have to open it in Notepad and save as a .txt as a manual workaround... Thoughts? 

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11

You need to have a '.' after the macro variable.

 

PROC EXPORT DATA= survey
OUTFILE= "\\fakepath\survey_&today..txt"
DBMS= tab
REPLACE;
PUTNAMES=YES;
RUN ;

 

View solution in original post

3 REPLIES 3
r_behata
Barite | Level 11

You need to have a '.' after the macro variable.

 

PROC EXPORT DATA= survey
OUTFILE= "\\fakepath\survey_&today..txt"
DBMS= tab
REPLACE;
PUTNAMES=YES;
RUN ;

 
Krysia24
Obsidian | Level 7

Oh wow! Such a silly mistake on my part. Thank you!

ballardw
Super User

SAS uses a period to denote the end of a macro variable in code.

Example if you want to append an _ to the end of a macro variable you use something like:

%let base = abc;
%let new = &base._;

%put &new.

If you do not have the period the above example statement

%let new =&base_;

will generate an error because the macro variable Base is not terminated and you have told SAS to use a macro variable named base_.

So when you need to have a period as part of the resolved value after a macro variable you use two.

The same thing is needed when using any of The of the SAS syntax elements like Library.dataset. If both your library and data set names are stored in macro variables the proper reference would be  &library..&dataset.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 705 views
  • 0 likes
  • 3 in conversation