How to recode date into a categorical variable?

How to recode date into a categorical variable?

book

Article ID: KB0074089

calendar_today

Updated On:

Products

Statistica

Description

This article shows how to use the "Recode" node to recode a date variable into different categories based on our example data "Stocks.sta".

 

Issue/Introduction

How to recode date into a categorical variable?

Resolution

1. Select Home|New|Workspace and click "Ok" in the "Create New Document" dialog with the default configuration of "All Validated Procedures".

2. In the "Select Data Source" dialog, select "Files...".

3. Open Stocks.sta data from the default Datasets folder(If not, navigate to Statistica example datasets folder) and the spreadsheet will be inserted into the workspace.

4. Click Data|Recode to insert the "Recode Variable" node into the workspace.

5. Click the top left wheel icon of the "Recode Variable" node to edit parameters in the node.

6. Click "Select Variables" to select "Date" as the recode variable.

7. Check "Create new Variable" if you want to create a new variable for the recoded categories. Or leave it as unchecked to replace the original variable with recoded categories. In this example, check this option and you will see the interface change with a blank to enter New Variable.

8. Enter "Timeline" as the New variable name and click "Define" to set the categorization rule.

9. In the prompted recode dialog, enter condition for each category and its corresponding New Value and click "OK". In this example,  "Timeline" will have a value of"Q1~Q2" for cases with Date before 1-Jul-91 and will have a value "Q3~Q4" for cases with Date on or after 1-Jul-91. Note specifying conditions for a date variable has its specific script format in Statistica. Check KB000031807 How to select cases based on dates? for more details.

You can also scroll down the bar in the middle to add more category conditions if needed. To specify a value for all "Other" conditions, check the bottom right section.

10. Click "OK" in the Recode Variable dialog. Note: you can click the "'+" to keep creating other new recode variables.

11. When returning to the workspace, click the green arrow icon on bottom left to run the node.

12. The resulted spreadsheet will have a new variable "Timeline" has case value: "Q1~Q2" if the Date is before 1-Jul-91 or "Q3~Q4' if Date is after 1-Jul-91. 

 

 

 

Additional Information

Legacy Article ID: 194717