DATA Step, Macro, Functions and more

write sas program

Reply
Occasional Contributor
Posts: 11

write sas program

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)

 

Super User
Posts: 6,932

Re: write sas program

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: write sas program

thanks for the reply.

PROC Star
Posts: 551

Re: write sas program

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;
Ask a Question
Discussion stats
  • 3 replies
  • 141 views
  • 1 like
  • 3 in conversation