- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm trying to convert num to date format such that I can extract the month and year from it in the form of MONYY.
The code that I've written is working well, but in the log is a little messy. Would appreciate the suggestions for making my code better. Thank you!
Input dataset (the dates could be different):
20190819 |
20190819 |
20190819 |
20190819 |
20190819 |
20190819 |
Output dataset expected: wouldn't mid getting rid of the SBDTE column either
DTE | SBDTE | mon |
20190819 | 21780 | AUG19 |
20190819 | 21780 | AUG19 |
20190819 | 21780 | AUG19 |
20190819 | 21780 | AUG19 |
20190819 | 21780 | AUG19 |
20190819 | 21780 | AUG19 |
Log:--the bigger my dataset, the log fills up with DTE= statements, which is what I would like to get rid of.
1014
1015 GOPTIONS ACCESSIBLE;
1016 data abc;
1017 set abc;
1018 SBDTE = Input( Put( DTE, 8.), Yymmdd10.);
1019 Put SBDTE = Date9.;
1020 mon=put(SBDTE, monyy5.);
1021 run;
DTE=19AUG2019
DTE=19AUG2019
DTE=19AUG2019
DTE=19AUG2019
DTE=19AUG2019
DTE=19AUG2019
NOTE: There were 6 observations read from the data set WORK.ABC.
NOTE: The data set WORK.ABC has 6
observations and 3 variables.
NOTE: DATA statement used (Total process time):
real time 5.39 seconds
cpu time 0.01 seconds
My code: the formata nd informat for DTE is num 11. and length is 8.
data abc;
set abc;
SBDTE = Input( Put( DTE, 8.), Yymmdd10.);
Put SBDTE = Date9.;
mon=put(SBDTE, monyy5.);
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"Log:--the bigger my dataset, the log fills up with DTE= statements, which is what I would like to get rid of."
So you could get rid of
Put SBDTE = Date9.;
Basically I am assuming you were using put statements while testing/debugging or to know what is assigned to SBDTE variable during each iteration of the datastep before the implicit return occurs , eventually writing the contents of the output buffer to the output dataset. In a production code, you don't need any of those. So removing the PUT statement will make sure your LOG is clean
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"Log:--the bigger my dataset, the log fills up with DTE= statements, which is what I would like to get rid of."
So you could get rid of
Put SBDTE = Date9.;
Basically I am assuming you were using put statements while testing/debugging or to know what is assigned to SBDTE variable during each iteration of the datastep before the implicit return occurs , eventually writing the contents of the output buffer to the output dataset. In a production code, you don't need any of those. So removing the PUT statement will make sure your LOG is clean
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content