/* 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.
*/
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.