DATA Step, Macro, Functions and more

SAS Query - Audit Trail

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 78
Accepted Solution

SAS Query - Audit Trail

I would like to set the reason change to "ABC", may I know how to put _reason_change_ into the audit trail dataset? Thanks.

 

LIBNAME test 'D:\TEST';

 

DATA ACURA test.AUDI;
SET SASHELP.CARS;
IF MAKE EQ 'Acura' THEN OUTPUT ACURA;
IF MAKE EQ 'Audi' THEN OUTPUT test.AUDI;
RUN;

 

proc datasets lib=test;
audit Audi;
initiate;
USER_VAR _REASON_CHANGE_ $30;
quit;

 

PROC APPEND BASE=test.AUDI DATA=ACURA;
RUN;

 

DATA AUDITCHK;
SET test.AUDI(type=audit);
RUN;

 

DATA CHK;
SET test.AUDI;
RUN;


Accepted Solutions
Solution
‎09-13-2017 07:28 AM
PROC Star
Posts: 2,307

Re: SAS Query - Audit Trail

Did you see this message in your log?

 

WARNING: Variable _REASON_CHANGE_ was not found on DATA file.

 

This works:


data ACURA 
     TEST.AUDI(drop=_REASON_CHANGE_);
  set SASHELP.CARS;
  _REASON_CHANGE_='ABC';
  if MAKE = 'Acura' then output ACURA;
  if MAKE = 'Audi'  then output TEST.AUDI;
run;
 
proc datasets lib=TEST;
  audit AUDI;
  initiate;
  user_var _REASON_CHANGE_ $30;
quit;
     
proc append base=TEST.AUDI data=ACURA;
run;
 
data AUDITCHK;
  set TEST.AUDI(type=audit);
run;
 
data DATACHK;
  set TEST.AUDI;
run;

 

 

 

View solution in original post


All Replies
Solution
‎09-13-2017 07:28 AM
PROC Star
Posts: 2,307

Re: SAS Query - Audit Trail

Did you see this message in your log?

 

WARNING: Variable _REASON_CHANGE_ was not found on DATA file.

 

This works:


data ACURA 
     TEST.AUDI(drop=_REASON_CHANGE_);
  set SASHELP.CARS;
  _REASON_CHANGE_='ABC';
  if MAKE = 'Acura' then output ACURA;
  if MAKE = 'Audi'  then output TEST.AUDI;
run;
 
proc datasets lib=TEST;
  audit AUDI;
  initiate;
  user_var _REASON_CHANGE_ $30;
quit;
     
proc append base=TEST.AUDI data=ACURA;
run;
 
data AUDITCHK;
  set TEST.AUDI(type=audit);
run;
 
data DATACHK;
  set TEST.AUDI;
run;

 

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 113 views
  • 0 likes
  • 2 in conversation