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
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;
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;
Thanks a lot DBailey the code is working fine.
Much appreciated with the immediate solution
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.