I have the following Proc SQL:
proc sql; create table dm1 as select STUDYID, DOMAIN, dm.SubjectID, USUBJID
from train.dm,train.cp where dm.subjectid=cp.subjectid order by subjectid ; quit;
USUBJID should be the a concatination of SubjectID and STUDYID: USUBJID = STUDYID || SubjectID . How can it be actualized inside the Proc SQL? Thank you!
proc sql; create table dm1 as select STUDYID, DOMAIN, dm.SubjectID, SubjectID||STUDYID as USUBJID
from train.dm,train.cp where dm.subjectid=cp.subjectid order by subjectid ; quit;
proc sql; create table dm1 as select STUDYID, DOMAIN, dm.SubjectID, SubjectID||STUDYID as USUBJID
from train.dm,train.cp where dm.subjectid=cp.subjectid order by subjectid ; quit;
If any of your your SubjectID are shorter than the defined length of the variable you may get unwanted spaces in the middle of the USUBJID variable:
data junk; length subjectid $ 10; subjectid = 'abc'; studyid = '123'; run; proc sql; select studyid, subjectid,SubjectID||STUDYID as USUBJID from junk; run;
If you don't want the space in the middle then use Cats(SubjectId,StudyId) as Usubjid
CATS/CATT functions can be used similarly to any other function within PROC SQL.
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.