## Getting Started with Vectors and Matrices

``` /****************************************************************/
/*          S A S   S A M P L E   L I B R A R Y                 */
/*                                                              */
/*    NAME: LISTDEMO                                            */
/*   TITLE: Getting Started with Vectors and Matrices           */
/* PRODUCT: IML                                                 */
/*  SYSTEM: ALL                                                 */
/*    KEYS: MATRIX                                              */
/*   PROCS: IML                                                 */
/*    DATA:                                                     */
/*                                                              */
/* SUPPORT: RHD                         UPDATE:                 */
/*     REF:                                                     */
/*    MISC:                                                     */
/*                                                              */
/****************************************************************/

proc iml;
reset fw=8 ;

item={carrots,cukes,lettuce,potatoes};
quant={1,3,2,6};
print item quant;
quant[1]=2;
print item quant;
price={1.23, .33, 1.45, .12};
print item quant price;
cost=price#quant;
print item quant price cost;
total=cost[+];  print total;
price= {1.23 1.21 1.18 1.43 0.99,
0.33 0.35 0.35 0.39 0.29,
1.45 1.41 1.42 1.52 0.99,
0.12 0.19 0.11 0.46 0.18};
stores={saleway kruger ag foodcity bigmart};
mattrib price rowname=item colname=stores;
print price;
cost=price#quant;
mattrib cost rowname=item colname=stores;
print cost;
lowcost = stores[cost[,>:<]];
print lowcost[r=item];
total=cost[+,]; print total [c=stores];
q = {2 2 2 2 1 2,
3 4 3 6 3 4,
3 3 3 5 3 4,
6 5 7 2 7 8};
month={jan feb mar apr may jun};
mattrib q rowname=item colname=month;
print q;
montot=price`*q;
mattrib montot rowname=stores colname=month;
print montot;
least = stores[montot[>:<,]];
print least[r=month];

```