BookmarkSubscribeRSS Feed
ajackson
Fluorite | Level 6

Hello,

 

I am requesting assistance on how to enter a query to find data that are flagged with errors within a dataset.

 

Thank you!

 

7 REPLIES 7
SASKiwi
PROC Star

You need to explain what you mean by "data that are flagged with errors within a dataset". What would be an example?

ajackson
Fluorite | Level 6

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? 

Tom
Super User Tom
Super User

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

Reeza
Super User

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

ajackson
Fluorite | Level 6

Great. Thank you!

Reeza
Super User

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 7 replies
  • 664 views
  • 4 likes
  • 4 in conversation