SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
kenjichan1212
Calcite | Level 5

Hi I'm just wondering how to convert this SQL statement into PROC SQL. I'm using SAS version 7.15

 

case
 when pdi.Value2 is not null
 then CONCAT(CAST(pdi.Value as decimal(18,3)), '-', CAST(pdi.Value2 as decimal(18,3)))
 else CONVERT(varchar(20), pdi.Value)
end as PeerDataValue

 

This is what I have so far and it doesn't seem to work;

any help is appreciated

case 
 when pdi.Value2 is not null
 then CAT((put(pdi.Value,18,3)), '-', (put(pdi.Value2,18,3)))
 else put(pdi.Value, $20) as pdi.Value
end as PeerDataValue,
1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Something like this should work. Not sure how many digits you want but SAS can only accurately store 15 or 16 (I've specified 15 digits with 3 decimal places). Value and Value2 must be numeric for this to work.

 

CATS(put(pdi.Value,15.3), '-', put(pdi.Value2,15.3))

View solution in original post

1 REPLY 1
SASKiwi
PROC Star

Something like this should work. Not sure how many digits you want but SAS can only accurately store 15 or 16 (I've specified 15 digits with 3 decimal places). Value and Value2 must be numeric for this to work.

 

CATS(put(pdi.Value,15.3), '-', put(pdi.Value2,15.3))

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 10634 views
  • 1 like
  • 2 in conversation