I am trying to take a column that has multipul values and create one var. I need them combined in to one before line.
DATA HAVE
item1 item2 item2 item3
TYPE BILCYCLE DBILC01 JOB
RUN BILCYCLE DBILC01 ANY
AFTER BILCYCLE DBILC01 -NONE-
BEFORE BILCYCLE DBILC01 QARBCDAF
BEFORE BILCYCLE DBILC01 QARBCD14
BEFORE BILCYCLE DBILC01 QARBC1CF
BEFORE BILCYCLE DBILC01 QBILCDAS
BEFORE BILCYCLE DBILC01 QBILCD20
EVENT BILCYCLE DBILC01 QASCHED.DBILC01
COND(S) BILCYCLE DBILC01 CCCHK RC(1:4095) FAIL
TYPE ABCDEFG1 DBILC0A JOB
RUN ABCDEFG1 DBILC0A ANY
AFTER ABCDEFG1 DBILC0A -NONE-
BEFORE ABCDEFG1 DBILC0A ANYNAME1
BEFORE ABCDEFG1 DBILC0A SOMENAM1
BEFORE ABCDEFG1 DBILC0A ANTHNAM1
EVENT ABCDEFG1 DBILC0A QASCHED.DBILC01
COND(S) ABCDEFG1 DBILC0A CCCHK RC(1:4095) FAIL
I only want to end up with one line for each different item1, if it has multipul BEFORE jobs I want to be combined into
one var "new ITEM"
DATA WANT
item1 item2 item2 newITEM
TYPE BILCYCLE DBILC01 JOB
RUN BILCYCLE DBILC01 ANY
AFTER BILCYCLE DBILC01 -NONE-
BEFORE BILCYCLE DBILC01 QARBCDAF QARBCD14 QARBC1CF QBILCDAS QBILCD20
EVENT BILCYCLE DBILC01 QASCHED.DBILC01
COND(S) BILCYCLE DBILC01 CCCHK RC(1:4095) FAIL
TYPE ABCDEFG1 DBILC0A JOB
RUN ABCDEFG1 DBILC0A ANY
AFTER ABCDEFG1 DBILC0A -NONE-
BEFORE ABCDEFG1 DBILC0A ANYNAME1 SOMENAM1 ANTHNAM
EVENT ABCDEFG1 DBILC0A QASCHED.DBILC01
COND(S) ABCDEFG1 DBILC0A CCCHK RC(1:4095) FAIL
Please try this untested code, before that sort the data using proc sort
data want;
length newitem $100.;
set have;
by item1 item2 item3 ;
retain newitem;
if first.item1 then newitem='';
if item3 ne '' then newitem=catx(' ', item3,newitem);
run;
Please try this untested code, before that sort the data using proc sort
data want;
length newitem $100.;
set have;
by item1 item2 item3 ;
retain newitem;
if first.item1 then newitem='';
if item3 ne '' then newitem=catx(' ', item3,newitem);
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 25. Read more here about why you should contribute and what is in it for you!
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.