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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 1650 views
  • 0 likes
  • 4 in conversation