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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 556 views
  • 0 likes
  • 3 in conversation