turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Categorizing dates by cycles

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-21-2010 10:12 PM

The data set I have has countless of records. The records are dated under variable FILMDATE. And FILMDATEs are categorized by cycles. I want to categorize the FILMDATEs. Here is my data below:

Cycle 1 if visited the clinic between 1969 and 1973

Cycle 2 if visited the clinic between 1971 and 1976

Cycle 3 if visited the clinic between 1975 and 1980

Cycle 4 if visited the clinic between 1978 and 1982

Cycle 5 if visited the clinic between 1981 and 1985

If the year in FILMDATE does not match the range defined for each cycle, then I want to keep the value of the cycle but create a new date variable where the incorrect value of FILMDATE is replaced by the year at midpoint of the range for each cycle (like 1971 for cycle 1).

How do I do this using PROC SQL?

Cycle 1 if visited the clinic between 1969 and 1973

Cycle 2 if visited the clinic between 1971 and 1976

Cycle 3 if visited the clinic between 1975 and 1980

Cycle 4 if visited the clinic between 1978 and 1982

Cycle 5 if visited the clinic between 1981 and 1985

If the year in FILMDATE does not match the range defined for each cycle, then I want to keep the value of the cycle but create a new date variable where the incorrect value of FILMDATE is replaced by the year at midpoint of the range for each cycle (like 1971 for cycle 1).

How do I do this using PROC SQL?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

04-25-2010 08:49 PM

I need to clarify. The data is above. Let's say I have the year 1972. That could be either cycle 1 or cycle 2. If I have the year 1979, that could be cycle 3 or 4. How do I do that in PROC SQL?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to deleted_user

04-26-2010 08:26 AM

"If I have the year 1979, that could be cycle 3 or 4. How do I do that in PROC SQL? "

So what should it be then? What's the logic to decide whether it's cycle 3 or 4?

Without knowing that one can't even start coding.

Does it have to be in SQL (and why) or would a SAS datastep do as well?

You will get the best answers by providing sample data (SAS data step creating this data) and then give an example of how the desired output should look like. Message was edited by: Patrick

So what should it be then? What's the logic to decide whether it's cycle 3 or 4?

Without knowing that one can't even start coding.

Does it have to be in SQL (and why) or would a SAS datastep do as well?

You will get the best answers by providing sample data (SAS data step creating this data) and then give an example of how the desired output should look like. Message was edited by: Patrick