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 (September 2002, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 24 Sep 2002 12:31:59 +0200
Reply-To:     Twan van Berkel <twan.vanberkel@ORGANON.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Twan van Berkel <twan.vanberkel@ORGANON.COM>
Organization: SURFnet BV
Subject:      Re: Data query

Solution:

data a; input IDD Var1 Var2 $ Sex $; cards; 1 5.00 chol F 1 2.00 HDL F 1 3.00 LDL F 1 25.2 BMI F 2 2.00 chol M 2 1.00 HDL M 2 3.00 LDL M 2 20.1 BMI M ; /*Note could replace list input with column or formatted input*/

proc transpose data=a; var var1; by IDD sex; id Var2; run;

proc print; run;

/*Another solution could be to do it in a plain dataset, because the above syntax works quite well if no double by keys are available. You get warnings from the transpose action. To suppress these warnings add the transpose option:

LET The LET option allows duplicate values of an ID variable within the DATA= data set or, if a BY statement is used, within a BY group. The observation containing the last occurrence of a particular ID value is transposed.

/* ID Chol HDL LDL BMI Sex 1 5.00 2.00 3.00 25.2 F 2. 2.00 1.00 3.00 20.1 M

IDD SEX _NAME_ CHOL HDL LDL BMI

1 F VAR1 5 2 3 25.2 2 M VAR1 2 1 3 20.1 */

Twan van Berkel

"Andrew Dixon" <adixon@DOH.HEALTH.NSW.GOV.AU> wrote in message news:sd9055a3.024@doh.health.nsw.gov.au... Hi all; I have a dataset that looks like this: ID Var1 Var2 Sex 1 5.00 chol F 1 2.00 HDL F 1 3.00 LDL F 1 25.2 BMI F 2 2.00 chol M 2 1.00 HDL M 2 3.00 LDL M 2 20.1 BMI M

and I want it to look like this: ID Chol HDL LDL BMI Sex 1 5.00 2.00 3.00 25.2 F 2. 2.00 1.00 3.00 20.1 M

How do I get there? Cheers Andrew


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