Hi SAS Users.
I have a code below to create the table work.industry_mtbv
proc sql;
create table work.industry_mtbv as
select year, INDC3,
median(wMAR_TO_BOO) as median_mtbv
from canus
group by INDC3,year
;
quit;
This means that median_mtbv will be calculated for each INDC3( industry) each year.
I want to add one more condition that: if INDC3 in ('NA', 'UNCLS', 'UQESQ') then median_mtbv=. (setting missing for median_mtbv if INDC3 is one of these three industries)
Can you please suggest to me how can I adjust the proc SQL above to add this condition?
Warmest regards.
Maybe the CASE-statement could be used, but imho this makes sql even less readable.
I would not use sql for anything, that could be solved by using a normal proc, so:
proc summary data=canus nway;
class indc3 year;
var wMAR_TO_BOO;
output out=work.industry_mtbv(drop= _type_ _freq_) median=median_mtbv;
run;
data work.industry_mtbv;
set work.industry_mtbv;
if indc3 in ('NA', 'UNCLS', 'UQESQ') then median_mtbv = .;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.