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

This is an embarrasing question, but what exactly is wrong with using the minus sign to count down a variable, such as inside this do-while loop?

data work.countdown;

count = -1;

do while (count NE -100);

       count -1;

end;

run;

proc print data=work.countdown;

run;

It runs perfectly with a plus sign, but once I use the minus sign the count variable turns red and I get this message in the log: "ERROR 180-322: Statement is not valid or it is used out of proper order."

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

Hi,

The count+1 thing is it's own type of statement, it's a SUM STATEMENT.  It needs to be a plus sign.  There is no equivalent DECREMENT statement.

If you want to do the same (set to 0, retain, use sum function) but decrement, you can do:

count + - 1;

or

count + (-1);

HTH,

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

2 REPLIES 2
Quentin
Super User

Hi,

The count+1 thing is it's own type of statement, it's a SUM STATEMENT.  It needs to be a plus sign.  There is no equivalent DECREMENT statement.

If you want to do the same (set to 0, retain, use sum function) but decrement, you can do:

count + - 1;

or

count + (-1);

HTH,

--Q.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
TurnTheBacon
Fluorite | Level 6

Thanks, that answers my question very well. Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1306 views
  • 1 like
  • 2 in conversation