```Date: Thu, 9 Aug 2007 07:11:40 -0700 Reply-To: sounpra@YAHOO.COM Sender: "SAS(r) Discussion" From: Song Organization: http://groups.google.com Subject: Re: generate normal data for 2-populations Comments: To: sas-l@uga.edu In-Reply-To: <1186668366.122610.43630@b79g2000hse.googlegroups.com> Content-Type: text/plain; charset="us-ascii" On Aug 9, 9:06 am, soun...@yahoo.com wrote: > Hi All, > > Can someone share with me a more efficient way to generate the > following data structure other than what I've done without PROC IML? > Group1 is normal (0,1) and Group2 is normal (1, 1). > > Thanks! > > sim group x1 > 1 A XXX > 1 A XXX > 1 A XXX > 1 B XXX > 1 B XXX > 1 B XXX > 2 A XXX > 2 A XXX > 2 A XXX > 2 B XXX > 2 B XXX > 2 B XXX > > Code: > > data group1; > seed1 = 123; > do sim = 1 to 2; > do i = 1 to 3; > group = 'A'; > x1 = rannor(seed1+sim); > output; > end; > end; > keep sim group x1; > run; > > data group2; > seed2 = 321; > do sim = 1 to 2; > do i = 1 to 3; > group = 'B'; > x1 = 1 + rannor(seed2+sim); > output; > end; > end; > keep sim group x1; > run; > > data mydata; > set group1 group2; > run; > > proc sort data=mydata; > by sim group; > run; > > Thanks! > > Song This was my other solution: data group1; seed1 = 123; seed2 = 321; do sim = 1 to 2; do i = 1 to 3; group = 'A'; x1 = rannor(seed1+sim); output; end; do i = 1 to 3; group = 'B'; x1 = 1 + rannor(seed2+sim); output; end; end; keep sim group x1; run; ```

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