Home SAS code is giving error for Do-While loop
Reply: 0

SAS code is giving error for Do-While loop

user4991
1#
user4991 Published in September 20, 2018, 10:38 pm

I need to print the fuel consumption and mileage of the car in SAS code. if given that mileage is 20 miles per gallon. It should stop generating output if fuel reaches to 10 gallon OR car travel 250 miles. My code:

data milage;
fuel=1;
do while (fuel<11);
miles =  fuel*20;
fuel+1;
output;
end;
run;

My output:

Code Output

The output for fuel needs to be started from 1 for first 20 miles which incorrect in my code. Any suggestion on what I am missing here.

Thanks!!

share|improve this question
  • try switching fuel+1 and output statements. You need to output the first fuel if you want it to start at 1. BTW, your title suggests that your Do-While loop throws an error. What is the error? – avid_useR Feb 13 at 18:40

1 Answer 1

active oldest votes
up vote 0 down vote
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.249773 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO