Hey Guys!
sorry for my english.. i try my best 🙂
Does someone know, how to select all data from my table:
between (AE = "A" AND AE = "E") OR between (AE = "A" AND AE = "B") OR between (AE = "B" AND AE = "E") OR between (AE = "B" AND AE = "B")
There are As for Start, Es for End or Bs for either Start or End in the data set.
I just like to select the rows between an A and an E (or A and B or B and E or even B and B) and put them in a new table.
so like: when AE is A: take all lines after (in time) until AE is E and put them in a new table
Table is sorted by IPID and than by measurement_time.
please look at the pic attached.
thank you very much!
Luie
table
Untested; when you post a question like this, you should provide your test data in the form of a data step, so I can recreate it to try the program;
Tom
data SetSwitch;
retain KeepSwitch 0;
set Have;
if AE = "A" then KeepSwitch = 1;
else if AE = "E" then KeepSwitch = 0;
else if AE = "B" & KeepSwitch = 1 then KeepSwitch = 0;
else if AE = "B" & KeepSwitch = 0 then KeepSwitch = 1;
run;
data SetVar;
set SetSwitch;
if KeepSwitch = 1 then if AE = " " then AE = lag(AE);
run;
data Want;
set SetVar;
if AE ^= " " then output;
run;
Untested; when you post a question like this, you should provide your test data in the form of a data step, so I can recreate it to try the program;
Tom
data SetSwitch;
retain KeepSwitch 0;
set Have;
if AE = "A" then KeepSwitch = 1;
else if AE = "E" then KeepSwitch = 0;
else if AE = "B" & KeepSwitch = 1 then KeepSwitch = 0;
else if AE = "B" & KeepSwitch = 0 then KeepSwitch = 1;
run;
data SetVar;
set SetSwitch;
if KeepSwitch = 1 then if AE = " " then AE = lag(AE);
run;
data Want;
set SetVar;
if AE ^= " " then output;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: