BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
swayto
Fluorite | Level 6

data hadoopdata;
price =100000;
do until(price gt 500000);
year+1;
price+(price*.10);
end;
run;

 

How to interprate DO WHILE statement that will generates the same results?

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Technically, the DO UNTIL loop executes at least once even if the original value of PRICE is 600000 instead of 100000.  To get a DO WHILE loop to produce the same outcome, you need to allow for that fact.  So:

 

data hadoopdata;
price=100000;
year+1;
price = price * 1.1;
do while (price le 500000);
  year + 1;
  price = price * 1.1;
end;
run;

View solution in original post

3 REPLIES 3
Amir
PROC Star

If you want to translate this to a do-while loop, then you could try:

 

data hadoopdata;
   price =100000;
   do while(price le 500000);
      year+1;
      price+(price*.10);
   end;
run;

 

 

Regards,

Amir.

PaigeMiller
Diamond | Level 26

@swayto wrote:

data hadoopdata;
price =100000;
do until(price gt 500000);
year+1;
price+(price*.10);
end;
run;

 

How to interprate DO WHILE statement that will generates the same results?


Would you please be kind enough to explain your question in more detail? It's not really clear what you are asking.

--
Paige Miller
Astounding
PROC Star

Technically, the DO UNTIL loop executes at least once even if the original value of PRICE is 600000 instead of 100000.  To get a DO WHILE loop to produce the same outcome, you need to allow for that fact.  So:

 

data hadoopdata;
price=100000;
year+1;
price = price * 1.1;
do while (price le 500000);
  year + 1;
  price = price * 1.1;
end;
run;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 935 views
  • 4 likes
  • 4 in conversation