I have a dataset below and would like to how to get the minimum price each month. The product could only be possibly priced in one of the months. So if the product has been priced in June, I would like to get the minimum price by product ID in June; if the product has been priced in July, then the minimum price by product ID in July should be attained.
ID June July
1 25 .
1 24 .
1 26 .
2 . 34
2 . 37
3 . 56
The desired the dataset I want to generate would be:
ID June July
1 24 .
2 . 34
3 . 56
I tried to do two if ... then do; group by ID; end; BUT the error shows up like " More than one BY statement specified for a SET, MERGE, UPDATE, or MODIFY statement." I am wondering how to solve this... Many thanks for anyone replies!
If you have variables named JUNE and JULY just take the MIN of them by ID.
proc summary data=have;
by id;
var june july;
output out=want min= ;
run;
If that is not how your data is actually structured then show a more representative example of the data you actually have.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.