BookmarkSubscribeRSS Feed
almmotamedi
Obsidian | Level 7

Hi,

 

I am trying to simply combine 5 tables (having the same variables),

 

 

libname XYZ "/sasdata/data/data3/Ali";

data XYZ.concatenation;
set XYZ.FBG_Analysis4 XYZ.FBG_ANALYSIS9 XYZ.FBG_ANALYSIS34 XYZ.FBG_ANALYSIS42

ERROR: Variable 'COT00503.D_SRVY'n has been defined as both character and numeric.

XYZ.FBG_ANALYSIS64;
run;

proc print data=XYZ.concatenation;
var C_ST C_DSTRB_AREA N_RSK ConstructionClass COT00503.C_CSP_CONST_CLS Current_FBG Updated_FBG Difference_percentage;
title 'Data Set CONCATENATION';
run;

 

 

But, I get this error. This variable 'COT00503.D_SRVY' is a "date" variable and I don't know how to solve the issue. Could you please help?

3 REPLIES 3
Reeza
Super User
You need to look at that variable across all your tables. You'll find that one is a character and others are date, then you'll need to make them all the same in a separate step. Ideally, you can fix this in how you import your data if possible.

You can also query the SASHELP.VCOLUMN table to see where the issue is.

proc sql;
create table types as
select libnmae, memname, name, type as
from sashelp.vcolumn where
libname='XYZ' and memname in ("FBG_ANALYSIS4", "FBG_ANALYSIS9", "FBG_ANALYSIS34", "FBG_ANALYSIS42", "FBG_ANALYSIS64")
and name='COT00503.D_SRVY';
quit;

almmotamedi
Obsidian | Level 7

Thank you Reeza. Could you please advise how to "make them all the same in a separate step" as you said?

PGStats
Opal | Level 21

Once you figure out which dataset contains the character date, you could fix it like this:

 

libname XYZ "/sasdata/data/data3/Ali";
data XYZ.concatenation;
set 
	XYZ.FBG_Analysis4 
	XYZ.FBG_ANALYSIS9 
		( rename='COT00503.D_SRVY'n=COT00503_D_SRVY_str 
		  in=special )
	XYZ.FBG_ANALYSIS34 
	XYZ.FBG_ANALYSIS42
	XYZ.FBG_ANALYSIS64;
if special then 'COT00503.D_SRVY'n = input(COT00503_D_SRVY_str, anydtdte.);
drop COT00503.D_SRVY_str;
run;

You might have to use a different informat.

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 3429 views
  • 0 likes
  • 3 in conversation