BookmarkSubscribeRSS Feed
niladri_routray
Calcite | Level 5

How to append 2 datasets having dataset1 has one column is character type and in dataset2 for same column is numeric.

 

example:

dataset1:- 19/02/2017 (numeric)

dataset2:- 19feb17(character)

 

3 REPLIES 3
Kurt_Bremser
Super User

Convert your variable in your second dataset (SAS date variables are better for date values than character variables):

data dataset2;
set dataset2 (rename=(date=_date));
format date ddmmyy10.;
date = input(_date,date7.);
drop _date;
run;

Then you can append without problems.

niladri_routray
Calcite | Level 5

thanks for the reply.

PeterClemmensen
Tourmaline | Level 20

This converts the numeric to character so they are comparable

 

data have;
informat date1 DDMMYY10.;
format date1 DDMMYY10.;
input date1 date2 $;
datalines;
19/02/2017 19feb17
;

data want(drop = date1);
	set have;
	length date3 $8.;
	format date1 date7.;

	date2 = upcase(date2);
	date3 = cats(date1);
run;

proc contents data = want;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 859 views
  • 1 like
  • 3 in conversation