LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (August 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 28 Aug 2001 09:22:37 -0500
Reply-To:     aldi@wubios.wustl.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Aldi Kraja <aldi@WUBIOS.WUSTL.EDU>
Organization: Washington University
Subject:      Re: random 0s and 1s:
Content-Type: text/plain; charset=us-ascii

Hi,

Here is a summary of responses (tested): Thank you, Aldi

data a1; seed=-1; do j=1 to 100; y5=rannor(seed)>=0; y4=round(ranuni(seed)); y3=ranbin(seed,1,0.5); y2=rantbl(seed,0.5)-1; if rannor(seed)<0 then y1=0; else y1=1; output; end; run;

Results in 100 loops: ==============

0 1 y1 50 50 y2 49 51 y3 56 44 y4 48 52 y5 52 48

Partial variable output: =============== Obs seed j y5 y4 y3 y2 y1

1 -1 1 1 0 1 1 0 2 -1 2 1 1 1 0 0 3 -1 3 0 1 0 0 0 4 -1 4 1 0 1 0 0 5 -1 5 0 1 1 1 1 6 -1 6 1 1 1 1 0 7 -1 7 1 0 1 1 0 8 -1 8 1 1 0 0 1 9 -1 9 1 0 1 1 0 10 -1 10 0 0 0 0 1 11 -1 11 0 1 1 0 0 12 -1 12 0 0 0 1 1 13 -1 13 1 1 0 0 1 14 -1 14 1 1 1 0 1 15 -1 15 0 1 1 1 1 16 -1 16 0 1 0 1 0 17 -1 17 0 1 0 1 1 18 -1 18 1 0 0 1 1 19 -1 19 0 0 0 0 1 20 -1 20 0 0 1 1 0


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