BookmarkSubscribeRSS Feed
riccardo88
Calcite | Level 5

Hallo!

 

For my Project I Need to create a random list of 1 and 0. Basically the classic head or tail program.

 

I know it should be pretty simple but I can´t find any solution in the old Posts.

 

Can someone help me?

 

Thank you!

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

From here:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001466748.htm

 

You can do:

data want;
  call streaminit(123);
  do i=1 to 1000;
    x=round(rand('uniform'));
    output;
  end;
run;
Ksharp
Super User

It is called Bernolli Trail/Distribution .

 

data want;
  call streaminit(123456789);
  do i=1 to 1000;
    x=rand('bern',0.5);
    output;
  end;
run;
proc freq data=want;
table x/missing;
run;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 634 views
  • 4 likes
  • 3 in conversation