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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 1 reply
  • 988 views
  • 2 likes
  • 2 in conversation