BookmarkSubscribeRSS Feed
mlogan
Lapis Lazuli | Level 10

Hi All,

Can I put both and Character and Numeric under the same variable and assign the variable type as Numeric? I wanted to merge these two table with set command and it says Table 1 code is Numeric and Table 2 Code is Character. 

Table 1:

Code
1
2
3
4
5

Table 2:

CodeName
1John
5Clara
BMike
4Dave
ALaura

Can I merge them like this with a set command so that all codes come?


CodeName
1
2
3
4
5
1John
5Clara
BMike
4Dave
ALaura



3 REPLIES 3
M_Maldonado
Barite | Level 11

probably not.

create a dummy variable in table 1 to make it character before merging it to table 2.

good luck!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

As has been mentioned above structurally you can only have a column which is of character or numeric.  You can however do this in one step:

data tab1;

  input code;

datalines;

1

2

3

4

5

;

run;

data tab2;

  input code $ name $;

datalines;

1 John

5 Clara

B Mike

4 Dave

A Laura

;

run;

proc sql;

  create table WANT as

  select  put(CODE,1.) as CODE,

          "" as NAME

  from    TAB1

  union all

  select  *

  from    TAB2;

quit;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1216 views
  • 0 likes
  • 4 in conversation