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:
Code | Name |
1 | John |
5 | Clara |
B | Mike |
4 | Dave |
A | Laura |
Can I merge them like this with a set command so that all codes come?
Code | Name |
1 | |
2 | |
3 | |
4 | |
5 | |
1 | John |
5 | Clara |
B | Mike |
4 | Dave |
A | Laura |
probably not.
create a dummy variable in table 1 to make it character before merging it to table 2.
good luck!
No. A variable defined as numeric can only hold numerical values.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.