compute based on the value of another field

Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash

mylesg
Posts: 1
Joined: Wed Oct 20, 2010 4:31 am

compute based on the value of another field

Postby mylesg » Fri Jun 15, 2012 9:56 pm

I don't much syntax- so would appreciate the help.

Say I have two variables:

Category (string) (Values can be a 1, 2, 3)
Cost (numeric)

I want to compute and create a new variable- Called "Calculation". In it.....

If Category is 3, then compute Cost + .2
If Category is 1 or 2, then compute Cost + .1

Thanks
Penguin_Knight
Posts: 473
Joined: Thu Apr 05, 2012 5:58 pm

Re: compute based on the value of another field

Postby Penguin_Knight » Sat Jun 16, 2012 2:21 pm

mylesg wrote: Category (string) (Values can be a 1, 2, 3)
Cost (numeric)

I want to compute and create a new variable- Called "Calculation". In it.....

If Category is 3, then compute Cost + .2
If Category is 1 or 2, then compute Cost + .1

Code: Select all

IF Category = "3" CostAdj = Cost + 0.2 .
IF ANY(Category, "1", "2") Cost = CostAdj + 0.1 .
EXECUTE .
Never overwrite any original variable, just call it "CostAdj" or something else.

Who is online

Users browsing this forum: No registered users and 1 guest

cron