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

I would like to create new field called Threshold based on the existing Test field. Is it possible to combine 2 code below with out an additional data step?

 

if test ="NP" then Threshold="> 14.80 = POS"
else if test="RB" then Threshold="> 14.64 = POS"
else if test="SP" then Threshold="> 19.66 = POS"


proc sql;
create table sample_final as
select sample, test, conc_calculated format=7.2, count(N) as Total_counts,
"" as Threshold,
from sample_calcs
group by sample, test, conc_calculated, Total_counts ;
quit;

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You can use a SQL CASE expression: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm 

Alternatively create a SAS format and use this format in your SQL to create the new variable. ...or don't even create the variable and just apply the format permanently to variable test.

View solution in original post

1 REPLY 1
Patrick
Opal | Level 21

You can use a SQL CASE expression: https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/sqlproc/n0a85s0ijz65irn1h3jtariooea5.htm 

Alternatively create a SAS format and use this format in your SQL to create the new variable. ...or don't even create the variable and just apply the format permanently to variable test.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 1145 views
  • 2 likes
  • 2 in conversation