BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DmytroYermak
Lapis Lazuli | Level 10

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  STUDYIDUSUBJID = STUDYID || SubjectID . How can it be actualized inside the Proc SQL? Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

 

 

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; 

View solution in original post

4 REPLIES 4
novinosrin
Tourmaline | Level 20

 

 

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; 
DmytroYermak
Lapis Lazuli | Level 10
Thank you, novinosrin. I asked but even not having checked on my own).
ballardw
Super User

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

 

Reeza
Super User

CATS/CATT functions can be used similarly to any other function within PROC SQL.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1703 views
  • 3 likes
  • 4 in conversation