Home SAS code is giving error for Do-While loop

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!!

• 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
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.18089239299297333, "perplexity": 2146.895080698754}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-39/segments/1537267156622.36/warc/CC-MAIN-20180920214659-20180920235059-00507.warc.gz"}