Hello guys,
I need your help with a little issue here:
I had a big database, then wrote Proc Sort, with some criterias and now have this:
id date cam amount
4701 11JAN2018 1 $30.00
4701 09JAN2018 0 $30.00
16044 16JAN2018 1 $40.00
28563 30JAN2018 0 $10.00
this is the proc sort I wrote before:
proc sort data=lib.RESULT out=lib.RESULT
nodupkey; by id cam;
RUN;
the question is that now I want to add something in my proc sort to tell sas (if id is duplicated), select those values when date is smaller and 'cam' is 1. these are the priorities. how can I do that? can anobody help?
You would need two steps:
proc sort data=lib.result; by id cam date; run; data want; set lib.result; by id; if first.id and cam=1; run;
Note, I have only done this based on the test data you provided (and provided not in a datastep!!). Would need to see some actual descriptive test data in the form of a datastep and what you want to see out at the end.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.