LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (August 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 12 Aug 2011 19:10:09 -0400
Reply-To:   "Peter H. Larsen" <phlarsen@YAHOO.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Peter H. Larsen" <phlarsen@YAHOO.COM>
Subject:   Need help with interesting matrix manipulation....

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


Back to: Top of message | Previous page | Main SAS-L page