I want to append these codes in one proc sql statement. Is that possible?
Is that possible with union or union corr?
PROC SQL; CREATE TABLE SGBSTDN AS
SELECT DISTINCT SGBSTDN_PIDM AS PIDM,
'Student' as StatusStudent
FROM STG.SGBSTDN
ORDER BY PIDM
;QUIT;
PROC SQL; CREATE TABLE SARADAP AS
SELECT DISTINCT SARADAP_PIDM AS PIDM,
'Applicant' as StatusApplicant
FROM STG.SARADAP
ORDER BY PIDM
;QUIT;
data STUDENT_PIDM;
merge SGBSTDN SARADAP ;
by pidm;
run;
data student_pidm2;
set student_pidm;
if StatusStudent='' then StatusStudent='Applicant';
run;
proc sql;
create table STUDENT as
select distinct pidm,
StatusStudent,
case
when b.Spbpers_sex IS NULL then "N"
when b.Spbpers_sex ='N' then "N"
when b.Spbpers_sex ='F' then "F"
when b.Spbpers_sex ='M' then "M"
END AS GENDER
from work.student_pidm2 as a left join stg.spbpers as b
on b.spbpers_pidm=a.pidm ;
quit;
Please let me know if it is possible?
@user24 wrote:
I have a bunch of codes. I want to make them together in one sql sel code
Is that possible with union or union corr?
What are you trying to do? Combine all your 3 SQL to one step?
Append all the tables together that you created?
Yes, i want to append them in one step. Sorry if i couldn't explain
Over time, I have come to the conclusion that having several simple steps instead of one complicated step is easier to maintain and usually more performant. This is particularly true when working with PROC SQL.
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 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.