Hi, I believe there is a way to do this and I don't remember from all the training classes on how this is done. My problem is I have a field with 200+ rows where the date is coming in, for example like 20060415. How do I convert this to become 04152006 w/o manually having to go through every single row?
If you would like to have a numeric result:
Create a calculated column with the following expression: INPUT(,YYMMDD8.)
Set the format of the calculated column to MMDDYYN8.
This wil give you a numeric column that will display the date a you want.
If you would like to have a character result:
Create a calculated column with the following expression: PUT(INPUT(,YYMMDD8.),MMDDYYN8.)
Hope this will help you.
If you are using EG 3.0.
Create a query on the base dataset and the query builder will appear.
In the "Select and Sort" tab all the columns of the base dataset are mentioned. In addition to this you can add calculated columns by pressing the "New ..." button.
A column definition GUI will appear. In this GUI there is an "Expression" window with a "change..." button next to it.
Click on it and the "Expression Builder" will appear.
Here you can either type in expressions or use the interface to enter expressions.
I hope this will help you to get what you want.
If you are posting to this group I assume that you are a SAS Enterprise Guide user (hopefully version 4 as that is the only version I have to hand). If you are not using Enterprise Guide this reply will not make sense.
I am also assuming that you start with a text file that you want to import into SAS.
If this is the case, I hope that the following steps help:
1) Click on File->Import Data....
2) In the Open Data dialog box point to the location and name of your text file containing your date information (Remember to set the Files of Type drop down menu to point to the type of file that you wish to import)
3)In the Import Data dialog box click on the Region to Import page (use the panel on the left hand side).
3.1) Tell the wizard whether your file has column headings in the first row.
3.2) Tell the wizard whether to import the entire file.
4) Click on the Text Format page (use the panel on the left hand side).
4.1) Tell the wizard how the various fields of your text file are delimited (ie comma, tab, space etc.)
5) Click on the Column Options page (use the panel on the left hand side).
5.1) For the Read-In Format choose the Date category entry: YYMMDDw.d and in the text boxes at the bottom of the dialog, tell the wizard that the Overall Width of your date values will be 8 (ie yyyymmdd)
5.2 For the Display Format choose the Date category entry of your choice but you probably want MMDDYYNw.d which will give you a value in the mmddyyyy style. Choose an Overall Width of 8. The N as the final character of the format name above tells SAS not to put any separators between the Year, the Month and the Day elements.
Well those steps should get you going but you really ought to read up on how the SAS System stores date and time and datetime values. Once you have read in a string of letters and/or numbers and told SAS they are a date, SAS will store them as an integer representing the number of days offset from 01Jan1960 and the world is your Oyster from there. It is important to note that the Display Format is just that, a mask that sits over the real integer value just for the benefit of us humans.