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

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

DTESBDTE mon
2019081921780AUG19
2019081921780AUG19
2019081921780AUG19
2019081921780AUG19
2019081921780AUG19
2019081921780AUG19

 

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;
1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

"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 

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

"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 

AJ_Brien
Quartz | Level 8
ah, that was what was happening! thank you!

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!

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
  • 2 replies
  • 902 views
  • 0 likes
  • 2 in conversation