@Mirou wrote:
Hi,
I need to join two sas tables using left join, the problem is that
N1 type is 12$. and N2 is a numeric 15.
i try to convert N2 to a character 15$. using a new variable N3 =put(N2,15$.)
but sas couldn't find a matches between the two tables, that was confirmed by the full join,
could you help me with that,
thanks,
proc SQL; create table C as select A.*,B.* from A left join B on A.N1 = b.N2 ;quit;
A couple of issues: Create character value from numeric using a numeric format with the Put statement: N3 =put(N2,15.)
Second is any value that is less than 15 digits will have leading blanks. So if you try to match '12345' with ' 12345' you do not get a match.
There are two ways to fix that. One is to use the -L option in the PUT function to left align the value so '12345 ' is created or to use
the Strip or Left functions to align the value.
data junk;
x = 12345;
y = put(x,f15.);
z = put(x,f15. -L);
u = strip(put(x,f15.));
run;
Use one the forms for Z or U above.
... View more