Hi ,
I am converting the character date to numeric, but only year and month values are not populating , i am using below code but getting error as "yymmd.) format not find.
Can any one suggest how to populate only year and month values.
Thank you,
Raja.
data have; input x $20.; y=input(x,anydtdte32.); format y yymmdd10.; cards; 2020-10-10 2022-08 ;
@raja777pharma wrote:
Can any one suggest how to populate only year and month values.
You want to take the first 7 characters of dtc_ and ignore the rest. You will also need to remove the hyphen from these dates.
dtc1_=compress(substr(dtc_,1,7),'-');
dt=input(dtc1_,yymmn6.);
format dt yymm6.; /* or any other format you want */
There is no informat YYMMD which is why you get the error. There is an informat YYMMDD (with two Ds on the end), but that won't work on the data in DTC_ that you show.
You might want to talk to whomever provides you with dates as character strings that this is not a good thing to do. Or if you converted the dates to character strings earlier in the program, don't do that. Keep dates as numeric variables.
Please do not provide the log as a screen capture. Please provide the log by copying it as text and then pasting it into the window that appears when you click on the </> icon.
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.
Ready to level-up your skills? Choose your own adventure.