array States[50] $12 State1-State50;
array States[50] $ State1-State50;
array years[6] yr2011-yr2016; array years[*] yr2011-yr2016;
yr2011
as element 2011,
the second as 2012, and so on. To do so, you can specify the lower
and upper bounds using a colon between the two values. array years[2011:2016] yr2011-yr2016;
do i=2011 to 2016;
array years[2011:2016];
array goal[4] g1 g2 g3 g4 (initial values);
array Var[4] (1 2 3 4);
data work.report (drop=i); /*1*/ set certadv.qsales; array sale[4] sales1-sales4; /*2*/ array Goal[4] (9000 9300 9600 9900); /*3*/ array Achieved[4]; /*4*/ do i=1 to 4; /*5*/ achieved[i]=100*sale[i]/goal[i]; end; run; proc print data=work.report noobs; run;
1 | The DATA step reads the Certadv.Qsales data set to create the Work.Report data set. You can drop the index variable from the new data set by adding a DROP= option to the DATA statement. |
2 | The first ARRAY statement creates an array, Sale. The four sales variables, Sales1 through Sales4, are being read from the input table Certadv.Qsales. |
3 | The second ARRAY statement creates the array, Goal, along with four variables Goal1 through Goal4, to provide the Sales goals for each quarter. The Goal array is assigned initial values of 9000, 9300, 9600, and 9900. |
4 | The third ARRAY statement creates the variables Achieved1 through Achieved4 to store the comparison of actual sales versus sales goals. |
5 | A DO loop executes four times to calculate the value of each element of the Achieved array (expressed as a percentage). |
array salesquota[5] _temporary_;
array Names[20] $ _temporary_;
data work.yrsales;
set certadv.qtrsales;
array Yr[4] SalesQ1-SalesQ4;
do Quarter=1 to 4;
Sales=Yr[Quarter];
output;
end;
run;
proc print data=work.yrsales; var Country Year Quarter Sales; run;
3.128.156.46