BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I have TAB1 with some variables. One of them is an identity variabel, called ID. In TAB2 I have only the variabel ID. I want to create TAB3, with records from TAB1, for the identities found in TAB2. The code below runs, but I get a warning:

WARNING: Variable ID already exists on file WORK.TAB3.

Q1: Why do I get that warning?

Q2: Is my code correct for the purpose I have described?

My code:

proc sql;
create table tab3 as
select * from tab1, tab2
where tab1.id=tab2.id;
quit;
1 REPLY 1
msg
Calcite | Level 5 msg
Calcite | Level 5
While you merge the datasets thru. proc sql code, the identical variables are not overwritten, unlike datastep merge. This can be visualized when this code is run removing the "Create table tab3 as" statement.

It is rationale that the variable's name should be unique.

So, you can do either of the following.

A) Select variables explicitly from the datasets.

proc sql;
create table tab3 as
select a.id, a. from tab1 a, tab2 b
where a.id=b.id;
quit;

By this way, you are not asking SAS to keep two "ID" variables, which it wont.

B) Using datastep merge.

Hope this is is useful.

Thanks

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 600 views
  • 0 likes
  • 2 in conversation