Hi Sas Community!
I tried to use the "YYQ5." informat to read year-quarter date, but cant get this quite right. Can any one catch what's going wrong with the following code?
Thank you!!! Have a nice weekend.
data temp;
input date YYQ5. prime 4.2;
datalines;
18Q01 3.45
18Q02 3.44
18Q03 3.23
18Q04 1.23
19Q01 2.12
19Q02 3.23
19Q03 1.42
;
run;
What makes you think there is a problem. You did not assign any format to DATE so the value displayed is the number of days since 1JAn1960.
The informat will assign a date value of the first day of the calendar quarter if you use a date format that will display day and month such as:
data temp; input date YYQ5. prime 4.2; format date date9.; datalines; 18Q01 3.45 18Q02 3.44 18Q03 3.23 18Q04 1.23 19Q01 2.12 19Q02 3.23 19Q03 1.42 ; run;
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
What makes you think there is a problem. You did not assign any format to DATE so the value displayed is the number of days since 1JAn1960.
The informat will assign a date value of the first day of the calendar quarter if you use a date format that will display day and month such as:
data temp; input date YYQ5. prime 4.2; format date date9.; datalines; 18Q01 3.45 18Q02 3.44 18Q03 3.23 18Q04 1.23 19Q01 2.12 19Q02 3.23 19Q03 1.42 ; run;
https://communities.sas.com/t5/SAS-Communities-Library/Working-with-Dates-and-Times-in-SAS-Tutorial/... has a PDF with much information about dates.
data temp;
input date yyq5. prime 4.2;
datalines;
18Q01 3.45
18Q02 3.44
18Q03 3.23
18Q04 1.23
19Q01 2.12
19Q02 3.23
19Q03 1.42
;
data got;
set temp;
new = date;
format new yyq5.;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.