- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
%if "&option"="Y" %then %do;
%make_dlm_file(dataset = base_recs, /* make_dlm_file creates a delimited output file */
filename = "/home/xxxxx/Output_&cntry._&id.txt",
dlmr = "|",
qtes = "no",
header = "no",
label = "no");
run;
Is it possible to add a timestamp to the output file name :- /home/xxxxx/Output_&cntry._&id_<timestamp>.txt
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is.
data _null_;
call symputx('timestamp', put(datetime(), B8601DT.));
run;
%make_dlm_file(dataset = base_recs, /* make_dlm_file creates a delimited output file */
filename = "/home/xxxxx/Output_&cntry._&id_×tamp..txt",
dlmr = "|",
qtes = "no",
header = "no",
label = "no");
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
&sysdate9. for date and &systime5. for time
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, it is.
data _null_;
call symputx('timestamp', put(datetime(), B8601DT.));
run;
%make_dlm_file(dataset = base_recs, /* make_dlm_file creates a delimited output file */
filename = "/home/xxxxx/Output_&cntry._&id_×tamp..txt",
dlmr = "|",
qtes = "no",
header = "no",
label = "no");
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, this is one of my favorite techniques for making a workbook with many sheets:
data _null_;
call symputx('nowyear', year(date()));
call symputx('nowmonth', month(date()));
call symputx('nowday', day(date()));
call symputx('nowhour', hour(datetime()));
call symputx('nowminute', minute(datetime()));
run;
%let myvar = %str(&nowyear)_%str(&nowmonth)_%str(&nowday)_%str(&nowhour)_%str(&nowminute);
%let title = "F:\Main\Studies\ICO_DUALS\EnrollBuckets\Documents\EN_%str(&myvar).xlsx";
PROC EXPORT DATA=RPT_T1 outfile= &title dbms=xlsx replace;
sheet="RPT_T1_TRAN";
run;
You can modify for .txt I believe. Repeat the proc export for as many as you would like.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@thomp7050 wrote:
Yes, this is one of my favorite techniques for making a workbook with many sheets:
data _null_; call symputx('nowyear', year(date())); call symputx('nowmonth', month(date())); call symputx('nowday', day(date())); call symputx('nowhour', hour(datetime())); call symputx('nowminute', minute(datetime())); run; %let myvar = %str(&nowyear)_%str(&nowmonth)_%str(&nowday)_%str(&nowhour)_%str(&nowminute); %let title = "F:\Main\Studies\ICO_DUALS\EnrollBuckets\Documents\EN_%str(&myvar).xlsx"; PROC EXPORT DATA=RPT_T1 outfile= &title dbms=xlsx replace; sheet="RPT_T1_TRAN"; run;
You can modify for .txt I believe. Repeat the proc export for as many as you would like.
Keep in mind that unformatted values for month, day, hours, minutes, seconds may prevent proper sorting of filenames. Use the z2. format to keep a leading zero.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
As a slight away from your question, I note that most people put date/time information in filenames/sheet names etc. Generally I find this practice to be a bit archaic and too much hard work. Say you send me a files named XYZ_ddmmmyyyy. txtx, then in a few days another with a different date. There then has to be faff about what file to use, how to get filename etc. I would hope that in this day and age all users are using some sort of automated versioning system, and dated filenames just does not fit that at all, you want the next file to have the same filename so you can look at the audit trail of the files. Just saying this as personally, if I am using a VCS then I would not accept structural items (filename, column names and such like) changing between files.