Hi,
I am trying to create a request file in sas (later I need to calculate abnormal returns and cumulative abnormal returns using evantus statements). I have an example provided to me by the Evantus support. The following statements are mentioned in the example:
/* Non-CRSP Single-Market Event Study on WRDS */
/* by Remote Submission from PC SAS */
/* Create the request file as a SAS data set. This */
/* example reads the security codes and event */
/* dates from lines pasted into this file, but you */
/* can use any SAS method to create your data set. */
/* Eventus also has the ability to use a text req- */
/* file instead of a SAS data set. */
data request;
input SecurityCode:$6. EventDat:yymmdd8.;
datalines;
H6576H 20050304
H0814P 20050624
H1112V 20050916
H9538X 20051213
H9778J 20060401
H7916H 20060415
H9538X 20060530
H3112V 20070212
H1184W 20070413
H9155V 20080314
H9155V 20080314
run;
I am doing the same thing. My statements are:
data trequest;
input dscd:$6. EventDat:yymmdd8.;
datalines;
740847 20000111
740639 20000201
993057 20000201
...(goes down 900 rows)
run;
but when I open the "trequest" file the dates look strange:
dscd | EventDat |
740847 | 14620 |
740639 | 14641 |
993057 | 14641 |
503762 | 14649 |
981698 | 14654 |
981860 | 14654 |
776807 | 14657 |
The log says:
NOTE: This SAS session is using a registry in WORK. All changes will be lost at the end of
this session.
2614 data trequest;
2615 input dscd:$6. EventDat:yymmdd8.;
2616 datalines;
NOTE: The data set WORK.TREQUEST has 937 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
3554 run;
NOTE: This SAS session is using a registry in WORK. All changes will be lost at the end of
this session.
NOTE: This SAS session is using a registry in WORK. All changes will be lost at the end of
this session.
3555 /**********************************************************************
3556 * PRODUCT: SAS
3557 * VERSION: 9.4
3558 * CREATOR: External File Interface
3559 * DATE: 02AUG15
3560 * DESC: Generated SAS Datastep Code
3561 * TEMPLATE SOURCE: (None Specified.)
3562 ***********************************************************************/
3563 data _null_;
3564 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
3565 %let _EFIREC_ = 0; /* clear export record count macro variable */
3566 file 'C:\Users\esy\Desktop\trequest.csv' delimiter=',' DSD DROPOVER lrecl=32767;
3567 if _n_ = 1 then /* write column names or labels */
3568 do;
3569 put
3570 "dscd"
3571 ','
3572 "EventDat"
3573 ;
3574 end;
3575 set WORK.Trequest end=EFIEOD;
3576 format dscd $6. ;
3577 format EventDat best12. ;
3578 do;
3579 EFIOUT + 1;
3580 put dscd $ @;
3581 put EventDat ;
3582 ;
3583 end;
3584 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection macro variable */
3585 if EFIEOD then call symputx('_EFIREC_',EFIOUT);
3586 run;
Could you please tell me what is wrong with my dates?
Thanks,
Niloo
You need to apply a display format to get you expected appearance.
For instance to get 01/11/2000 add:
format EventDat mmddyy10. ;
to the code when creating the variable.
OR modify the created export code to use the desired format. If a date value variable doesn't have an explicit date type format associated then proc export doesn't know that you want a date appearing value.
You need to apply a display format to get you expected appearance.
For instance to get 01/11/2000 add:
format EventDat mmddyy10. ;
to the code when creating the variable.
OR modify the created export code to use the desired format. If a date value variable doesn't have an explicit date type format associated then proc export doesn't know that you want a date appearing value.
Thank you so much ballardw.
Now that I've formatted the dates they look normal. But one more question, are the dates correct without formatting? I mean now my assumption is that the dates looked funny before the formatting but they are the same dates that I entered in the datalines and I can use them without formatting to calculate my Abnormal returns, am I correct?
I am following an example provided by the Evantus Support, and they did not format their date for the request file:
data request;
input SecurityCode:$6. EventDat:yymmdd8.;
datalines;
H6576H 20050304
H0814P 20050624
H1112V 20050916
H9538X 20051213
H9778J 20060401
H7916H 20060415
H9538X 20060530
H3112V 20070212
H1184W 20070413
H9155V 20080314
H9155V 20080314
run;
Thanks,
Niloo
As Kurt says, your dates are good.
An interesting exercise for the interested reader is to decrement and increment dates until SAS gives you an error to determine the range of valid dates it will handle a currently set up.
Hint: There is no Y3K issue to worry about (year 3000).
I'm not so sure about Microsoft's current approach to make to year 2101. But for most purposes I don't think I have to worry about it.
Thank you very much to all
I have another question about a data step, can I ask it here or open a new discussion?
Thanks,
Niloo
It is preferred on tis forum if the question is not closely related to the existing topic to start a new thread. Especially if the thread is marked answered. Many folks will not look for new questions in an answered thread.
Nothing is wrong with your data. You see the actual value that SAS stores when inputting dates, the number of days since 01jan1960. Assign a date format (start with date9., or ddmmyyp10.) to your variable, and the values will display correctly.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.