BookmarkSubscribeRSS Feed
swapnil
Calcite | Level 5

we need to take the input as the number from the user and display the fibonacci series

3 REPLIES 3
Subbarao
Fluorite | Level 6

Hi,

Below is the code.

data temp(keep=a);

a=0;

b=1;

n=100;

do while (count<n);

c=a+b;

output;

a=b;

b=c;

count+1;

end;

run;

If you wanted to have in Macro's, follow this.

%macro fib(n,fib=0,b=1);

%let count = 0;

%do %while(&count. < &n.);

%let c = %eval(&fib.+&b.);

%put &fib.;

%let count = %eval(&count+1);

%let fib=&b.;

%let b=&c.;

%end;

%mend;

%fib(10)

Ksharp
Super User
data _null_;
 a=1;b=1;  put a / b ;
 do i=1 to 10; 
  c=a+b; put c; a=b; b=c;
 end;
run;

Xia Keshan

SASMike
Obsidian | Level 7

Here's an example of the Fibonacci using an array. Smiley Happy

 

*OUTPUT THE FIBONACCI SEQUENCE TO THE SAS LOG;

DATA _NULL_;

ARRAY FIBONACCI {100};

DO I=1 TO DIM(FIBONACCI);

IF I<=2 THEN FIBONACCI{I}=1;

ELSE FIBONACCI{I}=FIBONACCI{I-1}+FIBONACCI{I-2};

PUT FIBONACCI{I};

END;

RUN;

 

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 3 replies
  • 6177 views
  • 0 likes
  • 4 in conversation