Hi,
I have a proc sql table that I have created but can anyone help me out with code (and where to insert it) so that missing values/not 'Yes' for the variable 'letter' in the created table VOLUMES (all of the accounts in b.letter have 'Yes' and when I left join, I want the records in the VOLUMES table that do not get assigned 'Yes' to be assigned 'No') are changed to a No i.e. (the condition I want to include is that if letter = . or letter in the created VOLUMES table is not equal to 'Yes', then letter = 'No')? Thanks!
Would there be code so it creates an output similar to an example I've created below?
In ac.letters as a:
-There is no letter variable but when I left join rb.account_information as b, I would like the records that are not matched by account ID to have 'No' assigned in the newly created VOLUMES table.
In rb.account_information as b:
-All of the records are assigned 'Yes' for the letter variable and this dataset will be left joined onto the ac.letters dataset to match the account ID and therefore give the matched accounts a 'Yes' answer for the letter variable.
Code so far:
proc sql;
create table VOLUMES as
select a.account_id,
a.date,
b.letter
from ac.letters as a
left join rb.account_information as b
on a.account_id = b.ACCOUNT_ID
;
quit;
Hi, I used your ifc concept because that was correct and changed it so that it was when letter is null (i.e. mix and match of both of your suggestions) and it's worked, thanks a lot for your help!
Correct code to use:
proc sql;
create table VOLUMES as
select a.account_id,
a.date,
ifc(b.letter is null, 'No', 'Yes') as letter length=3
from ac.letters as a
left join rb.account_information as b
on a.account_id = b.ACCOUNT_ID
;
quit;
Could you please explain with any sample dataset/table.
like this?
select a.ACCOUNT_ID
, a.DATE
, ifc(b.LETTER='Yes', 'Yes', 'No') as LETTER length=3
Like this?
select a.ACCOUNT_ID
, a.DATE
, ifc(a.ACCOUNT_ID is null, 'No', 'Yes') as LETTER length=3
Also, you seem to want a full join rather than a left join?
None of my proposals work?
Please provide sample data and expected output for that exact data.
Hi, I used your ifc concept because that was correct and changed it so that it was when letter is null (i.e. mix and match of both of your suggestions) and it's worked, thanks a lot for your help!
Correct code to use:
proc sql;
create table VOLUMES as
select a.account_id,
a.date,
ifc(b.letter is null, 'No', 'Yes') as letter length=3
from ac.letters as a
left join rb.account_information as b
on a.account_id = b.ACCOUNT_ID
;
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!
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.
Ready to level-up your skills? Choose your own adventure.