BookmarkSubscribeRSS Feed
coder1234
Obsidian | Level 7

Modify the DO statement to produce the following results. The DO statement will now be based on a list of values instead of a value that is incremented.

An alternate solution instead of: 

Spoiler
typing out the Year 1, Year 2... manually which the solution suggests, could use 

YearZ=cat('Year ', Year);

data IncMPG;
    set sashelp.cars;
    MPG=mean(MPG_City, MPG_Highway);

DO Year = 1 to 5; 
MPG=sum(MPG*1.03);
YearZ=cat('Year ', Year);
output;
end;
run;

title 'Projected Fuel Efficiency with 3% Annual Increase';
proc print data=IncMPG;
    var Make Model YearZ MPG;
	format MPG 4.1;
run;
title;
Which gives the same end result. 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 895 views
  • 0 likes
  • 1 in conversation