I am trying to code if a auditor_fkey=222 then companyIND=1.
For example if CompanyX is audited by auditor_fkey 222 in 2001, I need the companyIND to show up for that CompanyX regardless of the year (every time the company is in the database).
The issue I am running into is I need that 1 to show up for each time the company (company_fkey) was audited by a certain auditor based on the auditor_fkey.
Thank you!
I am trying to figure out how to do an indicator variable for any company_fkey that has ever been associated with a particular auditor_fkey.
Thank you!
Hello @dlazer1,
Your question requires more details before experts can help. Can you revise your question to include more information?
Review this checklist:
To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message. From there you can adjust the title and add more details to the body of the message. Or, simply reply to this message with any additional information you can supply.
SAS experts are eager to help -- help them by providing as much detail as you can.
This prewritten response was triggered for you by fellow SAS Support Communities member @PGStats
.Show us data you have, and data you want. I'm not convinced I understand what you want.
@dlazer1 wrote:
I am trying to code if a auditor_fkey=222 then companyIND=1.
For example if CompanyX is audited by auditor_fkey 222 in 2001, I need the companyIND to show up for that CompanyX regardless of the year (every time the company is in the database).
The issue I am running into is I need that 1 to show up for each time the company (company_fkey) was audited by a certain auditor based on the auditor_fkey.
Thank you!
You in your example if audited in 2001. Would you need to have that apply for years prior to 2001?
If that is the case then something like this:
proc sql; create table want as select a.*, ( not missing(b.company_fkey)) as companyIND from have as a left join (select company_fkey from have where auditor_fkey=222) as b on a.company_fkey=b.company_fkey ; quit;
This did not output what I'm looking for.
Here is an example and the indicator is how I need it coded. Basically if any year, an auditor_fkey for any company_fkey is there, then there needs to be an indicator.
@dlazer1 wrote:
This did not output what I'm looking for.
Here is an example and the indicator is how I need it coded. Basically if any year, an auditor_fkey for any company_fkey is there, then there needs to be an indicator.
No actual input data
No actual example output
And your document doesn't actually clear much up as you don't show where the desired "auditor_fkey" values to select come from or use to create the indicators might be.
You show values of auditor_fkey of
xxxxxx50
2
xxxxxx51
xxxxxx52
1
HOW in a generic sense as in a programmable rule are we to derive that the only auditor_fkey values you want are
xxxxxx50
xxxxxx51
xxxxxx52
If the rule is any auditor_fkey that start with xxxxxx then state that as part of the processing logic. IF your xxxxxx are actually masking critical information that changes from record to record then we need to know that as well.
Did the example I provided work for that stated auditor_fkey value? If not then you need to provide lots more information about why not:
"This did not output what I'm looking for" is awful vague especially since there was no example provided of the desired output.
Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.