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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1376 views
  • 4 likes
  • 4 in conversation