BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MirLuie
Calcite | Level 5

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

 

tabletable

 

1 ACCEPTED SOLUTION

Accepted Solutions
TomKari
Onyx | Level 15

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;

View solution in original post

2 REPLIES 2
TomKari
Onyx | Level 15

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;
MirLuie
Calcite | Level 5
thank you sooo much! you made my day!

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1828 views
  • 0 likes
  • 2 in conversation