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

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 1089 views
  • 0 likes
  • 2 in conversation