Hi Guys,
I hope to get a data quality report which includes the following indicators:
var | mean | std | min | max | N | Q1 | median | Q3 | IQ_Range | n_low | n_low_percent | n_high | n_high_percent | n_far_low | n_far_low_percent | n_far_high | n_far_high_percent | null_rate | missing | missing_percent |
Could anyone show me the respective code in SAS proc print, or proc freq, or other useful SAS procedure?
Many appreciation.
Most of what you want can be gained from a proc means procedure:
Thank you. I got most of them, but could not get the percentage ones. Could you help me?
Without some test data (in the form of a datastep) I can only give generals. Percents are just count() / N, so you can do these in a datastep. You may need to proc freq your data to get counts, merge that on.
Hi, my dataset is like this:
ID | OPENTIME | CLOSETIME | GENDER | GRADE | LOANS | FLAG |
1 | 98 | 121 | F | A | 1200 | Y |
2 | 95 | 115 | M | B | 1300 | Y |
3 | 96 | 114 | M | C | 1500 | N |
4 | 99 | 120 | F | D | 1600 | Y |
5 | 98 | 107 | F | E | 1700 | N |
The following is the code I use:
proc means data=table n mean min max std q1 q3 qrange median nmiss ;
var _numeric_;
run;
proc freq data=table;
tables _character_;
run;
But the results for numeric variables do not include the percentages. Could you help me, as I want to get all those results in one report.
Sorry, I don't have time to write a whole report for you. Use those procedures, then merge the required data together, and datastep to calculate any further numbers you need.
One thing to consider for percentages is what is the numerator and denominator to be used. I don't believe you have specified that in any way clear enough. Likely the way will be to create the appropriate Sums in Proc means/summary and then in a data step calculate the percentages.
Or perhaps Proc Report or Tabulate using the data for a report will allow the percentage calculations.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Early bird rate extended! Save $200 when you sign up by March 31.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.