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

Hi, I had created a new variable (newid) in dataset 'A' by using concatenating 2 or more fields( which I later deleted from the dataset)

This is how dataset A looks:

oldidsortidnewidOthervariable1Othervariable2Othervariable3
341A0101E
562A0102E
783A0102E

I need to use the newid in dataset A to merge it with dataset B . It will be merged by variable oldid. This is how dataset B looks:

Oldidothervariables...
34 xxx
34 xxx
56 xxx
56 xxxx
78 xxxx
78 xxx
37 xx
37 xx
48 xx
48 xx

I need to have a final dataset that looks like this ;

Oldidsortidnewid
341A0101E
341A0101E
562A0102E
562A0102E
783A0102E
783A0102E
37.
37.
48.
48..

For the merge ,I need only  the oldid , sortind and newid from dataset A, so I created  a dataset called temp:

data temp (keep=oldid sortind newid);

set A;

run;

It gives me a warning saying ...WARNING: The variable newid in the DROP, KEEP, or RENAME list has never been referenced ...and the dataset temp has no variable newid.

Could anyone tell me why its doing that?

Any suggestions would be very helpful.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I would double check spelling of the variable. Another possibility is that all values of newid are missing.

A proc sql solution that doesn't require a separate subsetting step.

proc sql;

     create table temp as

     select b.oldid, a.sortid, a.newid

     from b left join a on b.oldid=a.oldid;

quit;

View solution in original post

2 REPLIES 2
ballardw
Super User

I would double check spelling of the variable. Another possibility is that all values of newid are missing.

A proc sql solution that doesn't require a separate subsetting step.

proc sql;

     create table temp as

     select b.oldid, a.sortid, a.newid

     from b left join a on b.oldid=a.oldid;

quit;

dr2014
Quartz | Level 8

Thanks @ballardw I will work on your suggestions and use the left join...(The 'sortid/sortind' was a typo error here)

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 6327 views
  • 1 like
  • 2 in conversation