BookmarkSubscribeRSS Feed
brywhi11
Calcite | Level 5

I'm still new to SAS and I'm not sure if it can be done but though I would
ask. I'm trying to build an IFF statement similar to what you can do in Access.

I have two columns (total paid and first payment). If total paid = first payment
then I don't what to return anything. If total paid is > the first payment I
want to divide the total paid by first payment i.e.

Here is what I used in access

%CHANGE: IIf([TOTAL PAID]<>[FIRST PAYMENT AMOUNT],([TOTAL PAID]/[FIRST
PAYMENT AMOUNT])-1)

3 REPLIES 3
Astounding
PROC Star

It's easier than you would think.  Something like this:

if total_paid ne first_payment then percent_change = (total_paid / first_payment) - 1;

Automatically, this statement does nothing when total_paid equals first_payment.

The harder part of the question is understanding your data.  Do you really have only two columns, and not a third column identifying who is making the payment?  Do you really have a column that repeats the first payment value for every row belonging to that person?  If the answer is yes, then adding the statement above should be all you need.

Good luck.

Tom
Super User Tom
Super User

Depends on where you want to "return" this value.

Normally for this type of calculation you would want to create a new variable.

Assuming you have variables named TOTAL_PAID and FIRST_PAYMENT_AMOUNT and want to create variable NEW.

if total_paid = first_payment_amount then new = .;

else new = (total_paid/first_payment_amount) -1 ;

Note that you should not use <> to mean NOT EQUAL in SAS as that is the symbol for the MAX operator.

brywhi11
Calcite | Level 5

Thank you both!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 721 views
  • 0 likes
  • 3 in conversation