BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Reeza
Super User

That's not making sense. Please post your proc contents. 

Bal23
Lapis Lazuli | Level 10

93

var1Num8 

# Variable Type Len Format Informat Label 6

var2Char4   
Reeza
Super User

No formats?

What does each one of those variables look like - to make sure?

 

Bal23
Lapis Lazuli | Level 10

var1  0234     0389      0423

 

var2   234       389        423

Reeza
Super User

data one;
input var1;
cards;
123
456
789
234
;
run;

data two;
input var2 $;
cards;
0123
0456
0789
234
;
run;

data two_formatted;
set two;
var1=input(var2, best12.);
run;

proc sort data=one; by var1; run;
proc sort data=two_formatted; by var1; run;

data merged;
merge one two_formatted;
by var1;
run;

Peter_C
Rhodochrosite | Level 12
In sql a join could convert the char to num
On input( table1.leadz, best15.) = inpur( table2.nolead, best15.)

But that join fails when the input function returns missing for unsuitable strings

To achieve similar results on a data step merge the numeric form of these values need to be converted in steps before the merge.
I/O impact can be minimised by these prior steps creating table1 and table2 as views

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 20 replies
  • 1295 views
  • 1 like
  • 5 in conversation