data xx;
input ID $ Price  UPC $;
cards;
c1y1001  0.00  001
c2y1001  0.00  001
c2y2003  0.00  003
c1y3001  1.00  002
c2y4001  2.00  005
c2y5003  3.00  004
;

data xx;
 set xx;
 array dum $ d001-d005;
 do over dum;
 if upc=substr(vname(dum),2) then dum=1; else dum=0;
 end;

proc print;
run;

----------------------
The SAS System              07:43 Tuesday, August 14, 2001  33

Obs      ID       Price    UPC    d001    d002    d003    d004    d005

 1     c1y1001      0      001     1       0       0       0       0
 2     c2y1001      0      001     1       0       0       0       0
 3     c2y2003      0      003     0       0       1       0       0
 4     c1y3001      1      002     0       1       0       0       0
 5     c2y4001      2      005     0       0       0       0       1
 6     c2y5003      3      004     0       0       0       1       0

for your real data, just change d005 to d260;

HTH

Ya Huang

> -----Original Message-----
> From: Larry Hai Che [mailto:che@OLIN.WUSTL.EDU]
> Sent: Monday, August 13, 2001 11:41 PM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: a matrix of price, index and dummy variables
>
>
> Dear all,
>
> I have a table which looks like this,
>
> ID          PRICE      UPC
> ccyyxxx    0.00         xxx
>
> there are around 23,000 different ID observations, therefore
> the matrix is
> 23,000(rows)*3(colmns)
> For ID:  "cc":city index,  "yy": week index and "xxx": upc index.
>
> I need to point out that same UPC(xxx) could correspond to
> different IDs. I
> have here 260 distinct UPC, which corresponds to 23,000 distinct IDs.
>
> I want to further creat a table which adds 260 columns of dummies
> corresponding to 260 UPCs, so the whole matrix(table) would be
> 23,000(rows)*(3+260)(colmns),  the headings of the 260 new
> columns would be
> "xxx"(UPC), i.e.,
>
> ID                  Price      UPC       001         002         003
> ....................................260
> c1y1001          0.00      001          1             0             0
> 0
> c2y1001          0.00      001          1             0             0
> 0
> c2y2003          0.00      003          0             0             1
> 0
> ................................
>
>
> I don't know whether this made it clear to you or not. 
> Basically I would
> add another 260 columns which are column vectors of dummy
> variables. For
> each row, when UPC=UPCof the column, dummy=1, otherwise dummy=0,
>
> I hope any experts would know how to program this. I appreciate your
> helps!!!
>
> Larry
>