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.

 

 

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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