Hello,
I am creating 3 tables using proc sql and I want to create a new column for each of them. I just know case when to create column based on different conditions. But here, I only want to create one to work like a lable: new column=secure the value would be Y
thank you.
In case you want same value in all observations, do:
proc sql;
create table want
as select *,
'Y' as secure
from have;
quit;
or use a datastep:
data want;
set have;
secure = 'Y';
run;
In case you want same value in all observations, do:
proc sql;
create table want
as select *,
'Y' as secure
from have;
quit;
or use a datastep:
data want;
set have;
secure = 'Y';
run;
Not 100% sure I understand your question but look into either:
COALESCE() to choose one field from the three that isnt' missing
or INDSNAME to identify the source data in a data step.
It may help to provide some example data of what one of the sets looks like and what the desired result.
If you want to create variable with the same value for everyrow the easiest is to have something like this in the Select clause:
"Y" as new_var
Example:
proc sql;
create table work.new as
select *, 'Y' as new_var
from sashelp.class;
quit;
A little confused about the question. But you can also add a new variable like this, using alter table and add. This would be in SAS, code is to add a new character variable, length 9, called staffID
proc sql;
alter table work.sqlinsas
add staffID char 9
;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.