/* 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.
*/
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.