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

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