Hey guys,
I have a pipe-delimited text file that I'm trying to import to a SAS table and the formatting is not going particularly well.
I have a column labeled "QRTR" which is essentially in this format: "2014-2". This value represents the 2nd quarter of 2014.
Is there a way for me to convert this charvar to a numeric with an INPUT statement, and then convert the numeric to its' correct format using yyqd.?
Thank you,
Sean
data example; x = "2014-2"; date= input(translate(x,'Q','-'),yyq6.); format date yyq6.; run;
The resulting date acutally is assumed to be the first day the calendar quarter. You can use date9. or other format to examine it if needed.
Read it in as character, replace - with Q and convert using ANYDTDTE informat.
data test;
informat date $8.;
input date $;
y = input(translate(date, "Q", "-"), anydtdte.);
format y yyqd.;
cards;
2012-3
2013-1
2014-2
2015-5
2016-1
;
run;
data example; x = "2014-2"; date= input(translate(x,'Q','-'),yyq6.); format date yyq6.; run;
The resulting date acutally is assumed to be the first day the calendar quarter. You can use date9. or other format to examine it if needed.
Thank you both! I added in your code to my data step and it worked beautifully.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.