Hello, I am trying to left join two datasets but it is failing miserably! Can someone help rectify this? I attached the pics of before and after in a pdf format. In the pics, you can see the simple log reg output and the other is for multiple log reg. The issue comes when I try to combine the dataset to generate one output and my rows don't merge properly resulting in missing values for adjusted odd ratios and p-values.
Thank you for the help rendered.
proc sql; create table logit_table as select a.*, b.M_OddsRatios_CI , b.M_p_value, b.M_global_P_value from simplelog1 a left join multilog1 b on a.Category=b.Category and a.Demographic_Characteristics=b.Demographic_Characteristics order by f_order; quit;
@sas_apprenant - By ensuring each of the two columns that you use to join the two tables have identical values for the rows that you want to match with each other. For example one of your columns contains missing values - these need to populated with the right values to match to the required column in the other table.
Post log text like you posted your code. DO NOT post pictures. Post example data as code (data steps with datalines), so we can quickly, easily and accurately recreate your datasets for testing.
To rectify your problem, follow Maxim 3: Know Your Data. Inspect your datasets for variable types, attributes and content. Be aware that leading blanks or non-displayable characters in or after the string values might throw off your intended matches.
Thank you for the reply. I am aware of knowing my data, even though I'm relatively new to sas compared to R. I am using sas studio, Where can I print the log file to? I tried using the code below, but there was no file.
proc printto log=file.log; run;
Just copy/paste the log from SAS Studio to a window opened with the {i} button.
@sas_apprenant wrote:
Thank you for the reply. I am aware of knowing my data, even though I'm relatively new to sas compared to R. I am using sas studio, Where can I print the log file to? I tried using the code below, but there was no file.
proc printto log=file.log; run;
You will have to manually edit the variables Demographic_Characteristics and Category in the two input datasets so they match correctly. Then the join will work properly
How do you reckon I go about doing that?
@sas_apprenant - By ensuring each of the two columns that you use to join the two tables have identical values for the rows that you want to match with each other. For example one of your columns contains missing values - these need to populated with the right values to match to the required column in the other table.
Thanks I see what you meant. I had to go in my code and remove one line to make it all compatible.
Appreciate your rendered thoughts.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.