I am trying to report on this data that is not consistent ( My key from Description should be #RUN)
example:
ID JOB DESCRIPTION
12301 ABC100 JOB RUN SUCCESS RUN# R12310
12302 ABC101 JOB DID NOT RAN
DO TO FAILURE RUN# R12311
12303 ABC102 JOB RUN SUCCESS RUN# R12312
12304 ABC103 JOB DID DID NOT RUN BECAUSE
CONDITION DID NOT SATISFY
IN RUN# R12313
12305 ABC104 JOB DID NOT RAN
DO TO FAILURE RUN# R12314
REPORT
ID JOB RUN_ID
12301 ABC100 R12310
12302 ABC101 R12311
12303 ABC102 R12312
12304 ABC103 R12313
12305 ABC105 R12314
You are going to have to do more work if you also need description as there is only one space between the description and the jobid. However, if you don't need the description, you can get away with:
data want;
informat job $6. run_id $6.;
input ID JOB @"RUN#" run_id;
cards;
12301 ABC100 JOB RUN SUCCESS RUN# R12310
12302 ABC101 JOB DID NOT RAN
DO TO FAILURE RUN# R12311
12303 ABC102 JOB RUN SUCCESS RUN# R12312
12304 ABC103 JOB DID DID NOT RUN BECAUSE
CONDITION DID NOT SATISFY
IN RUN# R12313
12305 ABC104 JOB DID NOT RAN
DO TO FAILURE RUN# R12314
;
proc print data=want;
var ID JOB run_id;
run;
It is one space between jobid and description, but the big idea is to have only RUN# from description.
Then did you try the code I suggested? I think it does exactly what you want.
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 how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.