Hello,
I am requesting assistance on how to enter a query to find data that are flagged with errors within a dataset.
Thank you!
You need to explain what you mean by "data that are flagged with errors within a dataset". What would be an example?
Hello,
I'm trying to figure out the total count of errors by error flag and quarter in my dataset. Would this be an if/then statement that I use?
@ajackson wrote:
Hello,
I'm trying to figure out the total count of errors by error flag and quarter in my dataset. Would this be an if/then statement that I use?
Sound like you just want to run PROC FREQ.
So assuming you have a error flag variable name ERROR_FLAG and a variable named DATE that has date values you could probably just use the YYQ format to group by quarter. So just do something like:
proc freq data=mydata ;
tables date * error_flag;
format date yyq6.;
run;
If there are a lot more distinct values of ERROR_FLAG than there are quarters you might want to reverse the two variables in the TABLES statement. Or perhaps add the /LIST option to the TABLES statement.
Thank you!
@ajackson wrote:
Hello,
I'm trying to figure out the total count of errors by error flag and quarter in my dataset. Would this be an if/then statement that I use?
Depends a bit on your data structure.
Assuming you have something like this:
Date | Error_Flag |
2022-10-23 | Error Type 1 |
2022-10-24 | Error Type 3 |
Then you can do something like this to get the results by quarter:
proc freq data=have; *have is the input data set;
table date*error_flag / list out=want;
format date yyq6.; *controls what level the errors are aggregated at;
*for monthly summary use yymmn6.;
run;
The results will be displayed and saved in a data set named want.
Great. Thank you!
What is an error?
If you're looking for data quality measures, that's a much bigger bag of worms.
https://www.lexjansen.com/mwsug/2010/stats/MWSUG-2010-182.pdf
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.