Hello,
Please refer on the data steps below:
data have;
length;
infile datalines delimiter='|' dsd truncover;
input job_id return_cd1 Trigger $ Prerequisite $;
datalines;
2|0|Exec|
11|1|Exec|
7|.|Not Exec|11,2
;
run;
data Job_Sch_Merge;
set have;
array statuses(1000) _temporary_;
length pending_job $100;
statuses(job_id) = return_cd1;
if find(Trigger,'Not Exec','i') and Prerequisite ne '' then do; /*This will list down pending pre-requisite jobs in pending_job column*/
do _n_ = 1 to countw(Prerequisite);
_job = scan(Prerequisite,_n_);
if statuses(_job) ne 0 then
pending_job = compress(catx(',',pending_job,_job),,'s');
end;
end;
drop _job /*return_cd1*/;
run;
data step Job_Sch_Merge will work fine as long as the Prerequisite of a job_id is above it (see above work.have).
However, if work.have is like the dataset below, it will have an issue. May i know how to fix data step Job_Sch_Merge? Thank you in advanced.
data have;
length;
infile datalines delimiter='|' dsd truncover;
input job_id return_cd1 Trigger $ Prerequisite $;
datalines;
2|0|Exec|
7|.|Not Exec|11
11|0|Exec|
;
run;
Expand your DATALINES statement:
infile datalines delimiter='|' dsd truncover;
so that missing values are correctly dealt with.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.
Ready to level-up your skills? Choose your own adventure.