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

I have several large datasets that are iteratively processed by several sas programs, some of which I am not the primary programmer for.  I'm trying to brainstorm an easy data driven way to hook into those programs and record the names of variables with at least one changed observation (independent of sort order).  I'm hoping sas tracks this somewhere behind the scenes and I can write a macro to tap into it without placing too much of a burden on the other programmers.

 

I currently can track input variables into each program, and I can track when new variables are being created by diffing proc summaries before and after the program is ran, but obviously checking for changed values is much harder and it would be very useful to track dependencies between these chains of programs.

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
PROC SCAPROC when you run the full process is one method.

PROC COMPARE is another method but a world of coding can't erase a lack of documentation.

View solution in original post

3 REPLIES 3
Reeza
Super User
PROC SCAPROC when you run the full process is one method.

PROC COMPARE is another method but a world of coding can't erase a lack of documentation.
maguiremq
SAS Super FREQ

Building on @Reeza, here's an example of how to output results that are different for some data sets using PROC COMPARE. You may need to tinker with some of the options here (if you only want the compare value, drop the outbase option) , but I think it shows what PROC COMPARE can do. It's a procedure I used heavily in a previous job. Edit: looking at your question again, I'm not sure if I totally answered the question. You want to know the value that differs and then return the variable name? It also assumes a sort, but you can avoid this with an ID statement instead of the BY statement, but it will send a warning about duplicate values if you have them in your data set. Also, if you want to see the report that PROC COMPARE produces, remove the NOPRINT option.

 

data have;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 6
;

data have_2;
input id value;
datalines;
1 2
1 3
1 4
1 5
1 7
;

proc compare out = work.want outnoequal outbase outcomp noprint
	base = have
	compare = have_2;
	by id;
	var value;
run;

 

weg
Obsidian | Level 7 weg
Obsidian | Level 7
Thanks, this was useful, I think I can copy the datasets before a program is run and then compare before and after using this method with the ID for the keys

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 3 replies
  • 776 views
  • 3 likes
  • 3 in conversation