Hello
I have a data set with bridge name, Condition, inspection and year
The condition of the bridge can have different number (4,5,6,7,8) for the same bridge and the bridge name is repeated in my data set, not all the bridges are repeated though.
I want to filter bridge that has at least 2 different conditions (I don't want to specify the condition Number neither the bridge name.) How could I proceed?
for example bridge P505 below has 3 condition (that is the type I want to keep) and bridge P416 only have 1 condition (I don't want to keep that). I have about 900 rows
thanks
It is not nice to discuss a requirement like "bridge" without explicitly tieing it to the variable name.
You don't indicate any need to consider the other variables
Something like this might work. You did not supply an example of what you actually expect the result to be.
"Filter" can have many meanings. This gets you a list of the "bridges" that could be used to select records with a join or data step merge.
proc sql;
create table multipleconditions as
select stucture_number_008, count(superstructure_cond_59) as condcount
from (select distinct stucture_number_008, superstructure_cond_59
from yourdatasetnamegoeshere)
group by stucture_number_008
having count(superstructure_cond_59)>1
;
quit;
Please post your data in a form that allows us to use it for testing.
Use a data step with datalines, and use a code box for posting.
sorry but I am not sure I understand what you mean by "use a code box"
It is not nice to discuss a requirement like "bridge" without explicitly tieing it to the variable name.
You don't indicate any need to consider the other variables
Something like this might work. You did not supply an example of what you actually expect the result to be.
"Filter" can have many meanings. This gets you a list of the "bridges" that could be used to select records with a join or data step merge.
proc sql;
create table multipleconditions as
select stucture_number_008, count(superstructure_cond_59) as condcount
from (select distinct stucture_number_008, superstructure_cond_59
from yourdatasetnamegoeshere)
group by stucture_number_008
having count(superstructure_cond_59)>1
;
quit;
proc sql;
create table want as
select *
from have
group by bridge<replace with correct variable names>
having count(distinct condition)>=2;
quit;
Replace the variable with your variable names and you can use the HAVING clause to filter your data.
@Blandine wrote:
Hello
I have a data set with bridge name, Condition, inspection and year
The condition of the bridge can have different number (4,5,6,7,8) for the same bridge and the bridge name is repeated in my data set, not all the bridges are repeated though.
I want to filter bridge that has at least 2 different conditions (I don't want to specify the condition Number neither the bridge name.) How could I proceed?
for example bridge P505 below has 3 condition (that is the type I want to keep) and bridge P416 only have 1 condition (I don't want to keep that). I have about 900 rows
thanks
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!
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.