Hello team,
How to point to another variable in a case statement in a proc sql?
I need to have some calculation after then instead of literal. Instead of something, I need to multiply the value of a variable in the table * by the value of another variable in the table. After then, it is a calculation of two values from two variables from same dataset.
Proc sql; create table junk as select *, case when sex= 'F' then 'something' when sex= 'M' then 'something else' else 'Error' end as newvar label='This is a Sex based value' from sashelp.class ; run;
Respectfully,
Blue blue
Can you elaborate please. Your question is not comprehensible.
Do refer to SAS documentation on Proc SQL some of your questions may be answered there.
If you provide a more detailed example of what you are trying to do then you can get a better answer.
It sounds like you want something like this:
proc sql;
create table junk as
select *
, case
when sex= 'F' then weight*height
when sex= 'M' then age
else .
end as newvar label='This is a Sex based value'
from sashelp.class
;
quit;
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.