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