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;

 

 

 

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 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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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