Hi, i want to extract the first date of a group, trying to use IF(...) combinded with min(..) but that doesn't seem to work with date. I want the following:
ID DATE WANTED
1 2022-01-01 2001-01-01
1 2022-08-10 2001-01-01
1 2001-01-01 2001-01-01
2 2020-05-02 2018-01-03
2 2018-01-03 2018-01-03
3 2022-08-08 2022-08-08
3 2022-08-08 2022-08-08
3 2022-10-15 2022-08-08
Do someone have a solution to this?
Best regards Filip
Are the dates sas-dates or strings?
@FilipAxelsson wrote:
I want them as SAS-dates since i then want to calculate the amount of days from the first date until now.
Does not answer the question. "Want" is not the response to an "are they" question.
The reason the question about if the values are currently date values is that if they are then they are numeric and query asking for the MINIMUM value by group would work. Character values, depending on how they are created may not work consistently with aggregates like Minimum.
Is this a Visual Analytics question?
Yes this is a SAS VA question
I can give you a Base SAS code solution:
data want;
format wanted yymmddd10.;
wanted = '31dec9999'd;
do until (last.id);
set have;
by id;
wanted = min(wanted,date);
end;
do until (last.id);
set have;
by id;
output;
end;
run;
That is sas code, im looking for a solution in SAS VA, Visual Analytics
@acordes wrote:
The DOW technique
Exactly. Learned it here on the communities.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.