/* 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.
*/
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.