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