No Type ID Month Amount
2411 Marine Cargo 1001 01APR2015 100
2411 Marine Cargo 1001 01MAY2015 200
2411 Marine Cargo 1001 01JUN2015 300
2411 Marine Cargo 1001 01AUG2015 100
2411 Marine Cargo 1001 01OCT2015
2411 Marine Cargo 1001 01NOV2015 150
2411 Marine Cargo 1001 01DEC2015 50
2411 Marine Cargo 1001 01JAN2016 100
2411 Marine Cargo 1001 01FEB2016 200
2411 Marine Cargo 1001 01MAR2016
2411 Marine Cargo 1001 01APR2016 300
2411 Marine Cargo 1001 01MAY2016 500
2411 Marine Cargo 1001 01JUN2016 20
2411 Marine Cargo 1001 01SEP2016
2411 Marine Cargo 1001 01OCT2016 300
2411 Marine Cargo 1001 01DEC2016
I need the last year month value against the current one. Few sequence in the months column is missing like 01JUL2015, 01SEP2015 in the year 2015 and 01JUL2016, 01JUL2016 and 01NOV2016 , 01JAN2017, 01FEB2017, 01MAR2017 in the year 2016. I need Current year month-last year month ex (01Apr2016-01Apr2015)
I need the below results
No Type ID Month Amount LY_Amount
2411 Marine Cargo 1001 01APR2015 100
2411 Marine Cargo 1001 01MAY2015
2411 Marine Cargo 1001 01JUN2015 200
2411 Marine Cargo 1001 01JUL2015
2411 Marine Cargo 1001 01AUG2015 100
2411 Marine Cargo 1001 01SEP2015
2411 Marine Cargo 1001 01OCT2015
2411 Marine Cargo 1001 01NOV2015 150
2411 Marine Cargo 1001 01DEC2015 50
2411 Marine Cargo 1001 01JAN2016 100
2411 Marine Cargo 1001 01FEB2016 200
2411 Marine Cargo 1001 01MAR2016
2411 Marine Cargo 1001 01APR2016 300 100
2411 Marine Cargo 1001 01MAY2016 500
2411 Marine Cargo 1001 01JUN2016 20 200
2411 Marine Cargo 1001 01JUL2016 200
2411 Marine Cargo 1001 01AUG2016 100
2411 Marine Cargo 1001 01SEP2016
2411 Marine Cargo 1001 01OCT2016
2411 Marine Cargo 1001 01NOV2016 150
2411 Marine Cargo 1001 01DEC2016 50
2411 Marine Cargo 1001 01JAN2017 100
2411 Marine Cargo 1001 01FEB2017 200
2411 Marine Cargo 1001 01MAR2017
This is just one set of group variables (2411 Marine Cargo 1001) from so many in my entire data. I need the missing months in the column month for that particular and also the group variable values which is 2411, Marine Cargo, 1001 for the same.
I can then try lag function, lag12 for the same or intnx function or some sort of join.
I understood that you want to add observations for expected but missing month, but what rules are modifying Amount?
The amount should be zero for missing months. It should have blank values. and the character or group values should be same like below
2411 Marine Cargo 1001
Fine. And now please explain why you have
No Type ID Month Amount 2411 Marine Cargo 1001 01MAY2015 200
in the first table, and no value for Amount in the same observation in the second table.
No Type ID Month Amount 2411 Marine Cargo 1001 01MAY2015
Please ignore thats typo error. In short I need month comparison from last year based on the same granular grouping.
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.