I have the following Proc SQL:
proc sql; create table dm1 as select STUDYID, DOMAIN, dm.SubjectID, USUBJIDfrom 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 USUBJIDfrom 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 USUBJIDfrom 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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.