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

Hi,

I am new to this forum and struggling with this query most of the SAS experts weren't able to provide me a solution yet. Any help will certainly be appreciated.

Ex: Assuming a dataset with only variable - Dummy_records which has data in chunks.

What i would like here is the datasets has to be split in to two and condition is the special observation in them - From the below table

Dataset 1 should have the records John, Joseph, Mark & Antony (pulling the records between CMSTART & CMEND)

Dataset 2 must have records between CISTART &  CIEND (Mike, Amy & Abel)

Dummy_records
CMSTART
John
Joseph
Mark
Antony
CMEND

CISTART

Mike

Amy
Abel
CIEND

Probable approach i could think of -

1. A condtion such as between in SQL which could wokr for text strings (if exists)

2. Insert a flag  to differeniate CM records and CI records.

Please let me know if anymore information is required.

Thanks,

Hari Prasad

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

data DS1 DS2;

set have;

retain key;

if dummy_record = 'CMSTART' then key='CMSTART';

else if dummy_record='CMEND' then key='';

else if dummy_record='CISTART' the key='CISTART';

else if dummy_record='CIEND' then key='';

else do;

     if key='CMSTART' then output ds1;

     else if key='CISTART' then output ds2;

end;

run;

View solution in original post

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

data DS1 DS2;

set have;

retain key;

if dummy_record = 'CMSTART' then key='CMSTART';

else if dummy_record='CMEND' then key='';

else if dummy_record='CISTART' the key='CISTART';

else if dummy_record='CIEND' then key='';

else do;

     if key='CMSTART' then output ds1;

     else if key='CISTART' then output ds2;

end;

run;

HariPrasad
Calcite | Level 5

Thanks a lot DBailey the code is working fine.

Much appreciated with the immediate solution

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 672 views
  • 2 likes
  • 2 in conversation