|
data xx;
input market col1 col2 col3 col4 col5;
cards;
1 . 3 . . .
2 1 . . 2 .
3 . . . . 1
4 . 2 2 . .
5 1 1 1 1 .
;
options missing=' ' nocenter;
data xx (drop=lstr i);
set xx;
length lstr $200;
array col(*) col:;
lstr='';
do i=1 to dim(col);
lstr=compress(lstr||'~'||col(i));
end;
lstr=compbl(translate(lstr,' ','~'));
do i=1 to dim(col);
col(i)=input(scan(lstr,i,' '),best.);
end;
proc print;
run;
---------------------
Obs market col1 col2 col3 col4 col5
1 1 3
2 2 1 2
3 3 1
4 4 2 2
5 5 1 1 1 1
HTH
Ya Huang
Larry Hai Che wrote in message <9n1g3m$n7p$1@newsreader.wustl.edu>...
>Dear all,
>
>I have a question about missing values,
>
>I have a dataset looking like the following,
>
>market col1 col2 col3 col4 col5
>1 . 3 . . .
>2 1 . . 2 .
>3 . . . . 1
>4 . 2 2 . .
>5 1 1 1 1 .
>
>As you could see, for each market(observation), there are some missing
>values in the 5 columns.
>
>I want to have the dataset look like the following,
>
>market col1 col2 col3 col4 col5
>1 3
>2 1 2
>3 1
>4 2 2
>5 1 1 1 1
>
>i.e., I want to delete the missing values in each observation(not deleting
>observations or columns which have missing values)and leave only the
>available values and an unbalanced matrix.
>
>Since each column also is a variable name, I couldn't just use another sort
>or transpose to do that.......
>
>I appreciate your comments, suggestions and helps!! Thanks,
>
>Larry
>
>
>
>
|