BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Batman
Quartz | Level 8

I'm using an SQL join to eliminate all records that have the same three variables.   It appears to do I what wanted (it drops 6 records that have the same hicn, yr and month) but I also get a warning.   Is there away to change this so I don't get the warning?

 

27 proc sql;
28 create table Onerecord as
29 select * from ByYrMo a inner join ByYrMo b
30 on a.hicn=b.hicn and a.yr=b.yr and a.mon=b.mon
31 group by a.hicn, a.yr, a.mon
32 having count(*)=1
33 ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: Variable HICN already exists on file WORK.ONERECORD.
WARNING: Variable Yr already exists on file WORK.ONERECORD.
WARNING: Variable Mon already exists on file WORK.ONERECORD.
WARNING: Variable FFS_Dis already exists on file WORK.ONERECORD.
NOTE: Table WORK.ONERECORD created, with 8349353 rows and 4 columns.

34 quit;

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Use a table alias to avoid ambiguity-

proc sql;
create table Onerecord as
select a.* 
from ByYrMo a inner join ByYrMo b
 on a.hicn=b.hicn and a.yr=b.yr and a.mon=b.mon
 group by a.hicn, a.yr, a.mon
 having count(*)=1

 

View solution in original post

1 REPLY 1
novinosrin
Tourmaline | Level 20

Use a table alias to avoid ambiguity-

proc sql;
create table Onerecord as
select a.* 
from ByYrMo a inner join ByYrMo b
 on a.hicn=b.hicn and a.yr=b.yr and a.mon=b.mon
 group by a.hicn, a.yr, a.mon
 having count(*)=1

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 358 views
  • 0 likes
  • 2 in conversation