DATA Step, Macro, Functions and more

How to write code to identify error

Reply
Occasional Contributor
Posts: 5

How to write code to identify error

Data consists of subject Id by visit and date so how to identify wrong date by program. As after visit 1 is date of enrollment. And I have given only 1 subject details if there are more then how to identify discrepancy error.

Subjid sex age visit date
101 M. 25. 1. 30-05-2016
101. M. 25. 2. 29-06- 2016
101. M. 25. 3. 25-07-2016
101. M. 25. 4. 26-02-2016
101. M. 25. 5. 25-08-2016

Trusted Advisor
Posts: 1,831

Re: How to write code to identify error

Posted in reply to Bhavanaa44

I understand that the date is given in a char type variable, in a format of ddmmyy10.;

While converting the date into num type you ususlly use the ddmmyy10. informat, or any other informat.

 

You can code: num_date = input(char_date, <informat>, ??);

in case of date error you will get missing value.

check the num_date is it missing or not.

SAS Super FREQ
Posts: 9,320

Re: How to write code to identify error

Posted in reply to Bhavanaa44
Hi:
Some questions:
1) Why is there a period (.) after every value except the first row? There's no period after 101 in the first row. Is this intentional? A typo? Does it mean something?
2) How do you identify a discrepancy? Of the above 5 rows, where is the discrepancy and what it your logic?
3) You said "As after visit 1 is date of enrollment" -- that doesn't make sense to me -- there are 4 rows after visit 1 does that mean there are 4 dates of enrollment? I would have expected visit 1 to be the date of enrollment AND the date of the first visit and that for every other visit, the date just represents the visit date? I don't understand how you can define that "after visit 1 is date of enrollment".

What code have you tried? What is your desired output?

Cynthia
Super User
Posts: 9,886

Re: How to write code to identify error

Posted in reply to Bhavanaa44

Converting the dataset to a data step and posting the resulting code here in the proper way (see my footnotes for both of these steps) will remove any ambiguity about your data and let us use it for testing. Additionally, post an example for how your datset should look like after processing.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 3 replies
  • 140 views
  • 0 likes
  • 4 in conversation