/* test data */
data x;
do seat_class_id = 0 to 6;
sum_departures_performed = seat_class_id * 10;
output;
end;
run;
/* wall-paper code */
data rdwest;
set x;
dep_perf_0 = 0; dep_perf_1 = 0; dep_perf_2 = 0;
dep_perf_3 = 0; dep_perf_4 = 0; dep_perf_5 = 0;
dep_perf_6 = 0;
if seat_class_id = 0 then dep_perf_0 = sum_departures_performed;
if seat_class_id = 1 then dep_perf_1 = sum_departures_performed;
if seat_class_id = 2 then dep_perf_2 = sum_departures_performed;
if seat_class_id = 3 then dep_perf_3 = sum_departures_performed;
if seat_class_id = 4 then dep_perf_4 = sum_departures_performed;
if seat_class_id = 5 then dep_perf_5 = sum_departures_performed;
if seat_class_id = 6 then dep_perf_6 = sum_departures_performed;
run;
/* array code */
data array;
set x;
array dp(0:6) dep_perf_0 - dep_perf_6;
drop i;
do i = 0 to 6; dp(i) = 0; end;
dp(seat_class_id) = sum_departures_performed;
run;
/* check */
proc compare base=rdwest compare=array;
run;
/* on lst - in part
NOTE: No unequal values were found. All values compared are exactly equal.
*/
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.