12-11-2017 12:10 PM
I have dates being generated in a numeric format of yymm (eg. 1706 = June2017).
I have been trying to substring it to grab the month and then convert it into "mmm" using monname3. but with no success. In the example above I am trying to grab "Jun".
As a test I have tried:
data test ;
However this always returns "Jan" in month?! Very confused, any help is much appreciated.
12-11-2017 12:24 PM
Dates, regardless of how you format them, are stored as number of days since a certain timepoint. Thus they always need to contain the three parts Year, month, and day, and from that the number of days can be derived. With this number of days you can then apply formats to display that data differently. Now when you say display 6 as a date format, it assumes the 6 means 6 days and converts that to be 6 days from the default timepoint, so always going to be Jan in this instance as 01JAN1966 (or whatever it is, can't think off top of my head) is 07Jan1966, displayed as month is Jan. What you want is a date:
data test ; mon='01jan2017'd ; month=put(mon,monname3.) ; run ;
12-11-2017 12:28 PM
12-11-2017 12:47 PM
I must not have even base SAS then, log reports that function cannot be accessed
You couldn't use the previous answer either if you don't have BASE SAS. What are you using?
12-11-2017 01:20 PM
SAS 8 was released in 1999 so that's 18 years old.....so you have an Ancient* version of SAS.
18 year olds are pretty unruly these days.
PS. That's the technical term
12-11-2017 12:39 PM
Convert it to a SAS date using INPUT and PUT.
data have; x= 1706; y = put(x, 8. -l); z = input(catt('20', y), yymmn6.); monName = put(z, monname3.); format z date9.; run; proc print data=have;run;
Need further help from the community? Please ask a new question.