SAS Programming

DATA Step, Macro, Functions and more
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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