BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jjadall1
Quartz | Level 8
Hello SAS Support Communities,
Here's what I'm looking for now with the attached dataset (new 10):
The variables of interest are:
1. Auditor_Key 
2. _Auditor_During_Restated_Period
3. _Auditor_During_Restated_Period0
4. _Auditor_During_Restated_Period1
5. _Auditor_During_Restated_Period2
 
If there is only 1 auditor in the 4 columns (_Auditor_During_Restated_Period, _Auditor_During_Restated_Period0, _Auditor_During_Restated_Period1, and _Auditor_During_Restated_Period2), then a new variable (Auditor) should be created with that value (the 1 auditor).
 
If there is more than 1 auditor in the 4 columns (_Auditor_During_Restated_Period, _Auditor_During_Restated_Period0, _Auditor_During_Restated_Period1, and _Auditor_During_Restated_Period2), then the new Auditor value should have the value in the Auditor_Key column.
 
Let me give you some examples:
1. Observation 1 only has a value (4) in the _Auditor_During_Restated_Period.  The other 3 columns (_Auditor_During_Restated_Period0, _Auditor_During_Restated_Period1, and _Auditor_During_Restated_Period2) are blank.  Therefore, the new Auditor variable should have a value of 4.
 
2. Observation 8 has a value (26516) for both _Auditor_During_Restated_Period and _Auditor_During_Restated_Period0.  The other 2 columns (_Auditor_During_Restated_Period1 and _Auditor_During_Restated_Period2) are blank.  Since the value (26516) is the SAME, then the new Auditor variable should have the same value (26516).
 
3. Observation 424 has a value of 16168 for _Auditor_During_Restated_Period and 2830 for _Auditor_During_Restated_Period0.  Since these values are DIFFERENT, then the new Auditor variable should have the Auditor_Key value (2830).
 
Please let me know if you have any questions.
 
God bless, best regards, and thanks so much for your help,
Jadallah
1 ACCEPTED SOLUTION

Accepted Solutions
jjadall1
Quartz | Level 8

data dissert1.new11;
set dissert1.new10;
array temp (*) _Auditor_During_Restated_Period _Auditor_During_Restated_Period0 _Auditor_During_Restated_Period1 _Auditor_During_Restated_Period2;
totalnum=n(_Auditor_During_Restated_Period, _Auditor_During_Restated_Period0, _Auditor_During_Restated_Period1, _Auditor_During_Restated_Period2);
count=0;
do i= 1 to dim(temp)-1;
if i=1 then count=1;
if totalnum=1 and temp(i) ne . then do;
newaudit=temp(i);
leave;
end;
if temp(i)=temp(i+1) then count+1;
if count=totalnum then do;
newaudit=temp(i);
leave;
end;
end;
run;

View solution in original post

1 REPLY 1
jjadall1
Quartz | Level 8

data dissert1.new11;
set dissert1.new10;
array temp (*) _Auditor_During_Restated_Period _Auditor_During_Restated_Period0 _Auditor_During_Restated_Period1 _Auditor_During_Restated_Period2;
totalnum=n(_Auditor_During_Restated_Period, _Auditor_During_Restated_Period0, _Auditor_During_Restated_Period1, _Auditor_During_Restated_Period2);
count=0;
do i= 1 to dim(temp)-1;
if i=1 then count=1;
if totalnum=1 and temp(i) ne . then do;
newaudit=temp(i);
leave;
end;
if temp(i)=temp(i+1) then count+1;
if count=totalnum then do;
newaudit=temp(i);
leave;
end;
end;
run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 646 views
  • 0 likes
  • 1 in conversation