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

Hello!

I'm trying to change the name of my outfile....

Currently I'm using today's date to stamp the date at the end of my file name. 

%let numdate = %sysfunc(today(), MONYY7.);
proc export data=WORK.FORMAT_FIELDS
outfile="Z:\Commercial Operations\TRANSITION\test\TERR_TRX_SENSORS&numdate..txt"
dbms=dlm
replace;
delimiter='|';
run;

So what I'm getting for my file name is TERR_TRX_SENSORSJULY2019.

This works great, however what I would like to do is instead of using today's date, I would like to use a date within my data set.

For example, In my WORK.FORMAT_FIELDS table, I have a field called CAL_MTH_DT.  The CAL_MTH_DT is 5/31/2019, so I would like it to be something like:

%let numdate = %sysfunc(CAL_MTH_DT, MONYY7.);
proc export data=WORK.FORMAT_FIELDS
outfile="Z:\Commercial Operations\TRANSITION\test\TERR_TRX_SENSORS&numdate..txt"
dbms=dlm
replace;
delimiter='|';
run;

That way my file name comes out as TERR_TRX_SENSORSMAY2019.

But this is working and I'm trying to figure out how to make the date the date from my data set if possible.

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
data _null_;
set work.format_fields (obs=1);
call symput('ts',put(cal_mth_dt,yymmn6.));
run;

proc export
  data=work.format_fields
  outfile="Z:\Commercial Operations\TRANSITION\test\TERR_TRX_SENSORS&ts..txt"
  dbms=dlm
  replace
;
delimiter='|';
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User
data _null_;
set work.format_fields (obs=1);
call symput('ts',put(cal_mth_dt,yymmn6.));
run;

proc export
  data=work.format_fields
  outfile="Z:\Commercial Operations\TRANSITION\test\TERR_TRX_SENSORS&ts..txt"
  dbms=dlm
  replace
;
delimiter='|';
run;
LRogers
Obsidian | Level 7

Thank you so much, Kurt!  

This worked great!!!!  Great learning for me!  

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 465 views
  • 0 likes
  • 2 in conversation