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 (June 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 27 Jun 2005 10:43:36 -0400
Reply-To:     Sigurd Hermansen <HERMANS1@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Sigurd Hermansen <HERMANS1@WESTAT.COM>
Subject:      FW: how to create a matrix in sas?
Content-Type: text/plain; charset="us-ascii"

For some reason this post did not reach the listserver yesterday .... SAS-L sure has changed! Paul Kent must be pleased to see the breadth and depth of expertise in SAS SQL programming demonstrated in this set of responses to a moderately complex problem. Sig -----Original Message----- From: Sigurd Hermansen Sent: Sunday, June 26, 2005 11:50 AM To: yue@yahoo.com; sas-l@uga.edu Subject: RE: how to create a matrix in sas?

Yue: A Cartesian product of the column values for name, age, and gender will give you the 3**3 possible triplets of three distinct values in each column. For that, declare a Cartesian product in SAS SQL : data test; input name: $char1. age gender: $char1.; cards; A 5 M B 9 M C 7 F ; run; proc sql; create table nameXage as select * from (select name from test), (select age from test), (select gender from test) ; quit; In the example you give, you list the Cartesian product of name and observed (age,gender)pairs. For that, declare a different Cartesian product in SAS SQL: proc sql;

create table nameXageGender as

select * from (select name from test),

(select age,gender from test)

;

quit;

Sig

________________________________

From: owner-sas-l@listserv.uga.edu on behalf of yue@yahoo.com Sent: Fri 6/24/2005 10:27 PM To: sas-l@uga.edu Subject: how to create a matrix in sas?

for example, i have the following dataset

name age gender ..... A 5 M B 9 M C 7 F

I want to get all possible combination between name and age to get output like this

name date gender ..... A 5 M A 9 M A 7 M B 5 M B 9 M B 7 M C 5 F C 9 F C 7 F

can this be done by merging with itself?

TIA


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