Desktop productivity for business analysts and programmers

Trouble using the minus sign for counting down a variable

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 89
Accepted Solution

Trouble using the minus sign for counting down a variable

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."


Accepted Solutions
Solution
‎09-08-2012 04:32 PM
Trusted Advisor
Posts: 1,213

Re: Trouble using the minus sign for counting down a variable

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.

View solution in original post


All Replies
Solution
‎09-08-2012 04:32 PM
Trusted Advisor
Posts: 1,213

Re: Trouble using the minus sign for counting down a variable

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.

Frequent Contributor
Posts: 89

Re: Trouble using the minus sign for counting down a variable

Thanks, that answers my question very well. Smiley Happy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 358 views
  • 0 likes
  • 2 in conversation