SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

How to generate natural numbers in output?

Reply
Frequent Contributor
Posts: 89

How to generate natural numbers in output?

I want output like

x

1

12

123

1234

1234

I have used ranuni function and do loop .

I am not getting?

Super User
Posts: 9,671

Re: How to generate natural numbers in output?

Is it what you are looking for ?

data _null_;

do i=1 to 20;

a=int(ranuni(-1)*10000);

put i a;

end;

run;

Xia Keshan

Frequent Contributor
Posts: 89

Re: How to generate natural numbers in output?

But.xia keshan, I want output like in below format

1

12

123

1234

12345

Super User
Posts: 9,671

Re: How to generate natural numbers in output?

Still hard to know what you are looking for .


data x;
 str='123456789';
 do i=1 to 9;
  num=input(substr(str,1,i),best32.);
  output;
 end;
run;

Xia Keshan

Ask a Question
Discussion stats
  • 3 replies
  • 334 views
  • 0 likes
  • 2 in conversation