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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

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;

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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