|
Hi Folks-
I think I have a relatively simple question for those of you who are
proficient with matrix manipulation and/or PROC SQL. The following is a
simplified dataset.
My data is currently in the following form:
options nocenter;
DATA survey;
Infile Cards MissOver ;
INPUT ID $ VAR1 $ VAR2 $ VAR3 $;
CARDS;
A X Y Z
B X Y
C X Z
D X
;
RUN;
I would like to have an example piece of code that can get the above
dataset to look like the dataset created below:
DATA results;
Infile Cards MissOver ;
INPUT ID $ X Y Z;
CARDS;
A .25 .5 .5
B .25 .5 .
C .25 . .5
D .25 . .
;
RUN;
Note that the unique character values in the dataset "survey" now become
the variables names in the "results" dataset. Also, I am looking for the
code to calculate the inverse (i.e. 1/# of occurences of each character
variable within the original dataset) and insert it into the new dataset.
For example, "X" shows up four times in the original dataset, so we insert
a 0.25 in each correct/respective place in the "results" dataset.
Since "Y" only occurs twice the inverse would be 0.50. Missing values
will need to be coded as empty numeric fields. My real dataset is much
larger, so there is the chance that the inverse value could be quite small
for some observations.
I look forward to hearing from you. As always, I really appreciate your
help.
-Peter
|