BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_apprenant
Fluorite | Level 6

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;

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

@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.

View solution in original post

7 REPLIES 7
Kurt_Bremser
Super User

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.

sas_apprenant
Fluorite | Level 6

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;
Kurt_Bremser
Super User

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;

 

SASKiwi
PROC Star

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

sas_apprenant
Fluorite | Level 6

How do you reckon I go about doing that?

SASKiwi
PROC Star

@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.

sas_apprenant
Fluorite | Level 6

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 833 views
  • 0 likes
  • 3 in conversation