0

Currently I'm trying to filter the output I have to display only products which have discounts greater than or equal to 60%. The variable discount lists all their values in the format such as 50%, 60% etc.

PROC SQL;
SELECT discount.Product_ID,Product_Name,Start_Date,End_Date,Discount
 FROM Final.discount AS d, Final.product_dim AS p
 WHERE d.Product_ID=p.Product_ID
 AND Discount >= 60%;
QUIT;

I dont know why this isn't working, but the error from the log tells me that the percent sign isnt recognized? How would I fix this to get the output I desire?

Dangerous Game
  • 103
  • 1
  • 1
  • 6
  • 1
    What datatype is Discount? If you're storing values as 50%, 60% (rather than 50, 60, etc) - is it a varchar / string datatype? – CoolBots May 05 '16 at 20:29
  • Agree with CoolBots...run a proc contents on the data set and find out what your variable is...you can potentially just wrap in quotes if it's a character - '60%', or just call out the number if its formatted as a number - 60 – SMW May 05 '16 at 20:31

1 Answers1

1

Assuming the variable is numeric with the PERCENTw.d format applied (so likely PERCENT5. given your display), you would write it like so:

Discount >= 0.6;

The PERCENTw.d format displays numbers between 0 and 1 as 0% - 100%.

If your variable is character, then you would probably need to convert it to a number first (as '100%' > '60%' is false).

input(Discount, PERCENT5.) >= 0.6

This is well covered in Rick Wicklin's blog post on the Do Loop.

Joe
  • 62,789
  • 6
  • 49
  • 67