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

I am attempting to do a calculated column in my SQL that takes

Merchandise_AMT - Changed_Price

There are several instances where the value in changed price is '.'   I tried doing a missing statement to replace all '.' with '0' but the calculation had the same affect.  Does anyone know how to treat the '.' as an actual zero so the calculation will work as intended?

DZ

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

I can't test it at the moment, but how about if you use the sum function?  e.g.:

data have;

  input x y;

  cards;

1 2

1 .

5 7

7 5

. 6

;

proc sql;

  create table want as

    select *,sum(x,y*-1) as diff

      from have

  ;

quit;

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

I can't test it at the moment, but how about if you use the sum function?  e.g.:

data have;

  input x y;

  cards;

1 2

1 .

5 7

7 5

. 6

;

proc sql;

  create table want as

    select *,sum(x,y*-1) as diff

      from have

  ;

quit;

TriciaA
Calcite | Level 5

Art297 has a good suggestion.

I have also used this method with success - basically I test if Price is empty and only do the calculation if it's not.  My else value can be 0 indicating no change or it could be amount if that makes more sense in your calculation.

,case

when price ge 0 then Amt - price

else 0 /*You may want this to be Amt*/

end as new_var

D_Z_
Obsidian | Level 7

God I love you guys/gals!!!  You are so smart. 

Thank yoiu so much for all of your input... both of you!

My report is finally completed!!!

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!

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