DATA Step, Macro, Functions and more

Finding Average Time til Completion

Reply
New User
Posts: 1

Finding Average Time til Completion

Hi,

 

I'm pretty new to SAS, running 9.4.  Appreciate any assistance, thanks in advance for reading my post.

 

I have successfully imported some data into SAS from an excel file which has three variables that I'm specifically trying to work with: Session_Date, Test_Date and Date_Pass.  This data is data on when a person who was tutored took a standardized test.  So Session_Date records the date they had a tutoring session, Test_Date records the date they initially took the test and Date_Pass records another date (could be same date) for the date on which they actually got a score which passed. 

 

I want to know what the average time til someone passes the test from when they tutored.  The data itself admittedly does not have dates for every single observation, as not every student who has tutored has tested, and not every student who has tested has passed.  My results generate only missing values; I would have thought that I'd get missing values where the operation can't be performed and then data when the variables are present as expected.

 

I was looking at a couple other threads that describe this but I think I must be doing something wrong.

 

This is my initial code that attempts to find the time between when someone tutored and when they tested.

 

DATA bstdates16172;
SET bstdate1617 ;
D_COMPLETION = INTCK ('dtday', Session_Date, Test_Date ) ;
put D_COMPLETION =;

RUN;

There are several points in the error log:

NOTE: Invalid argument to function INPUT at line 50 column 15.
NOTE: Invalid argument to function INPUT at line 51 column 15.
First_Name=Tatiana Last_Name=Alcindor WCU_ID=820968 Major=Lang/Culture: Spain
Double_Major=Teacher Ed Spanish Session_Date=31OCT2016 Test_Date=43040 Date_Pass=43040
Primary_Concerns=Reviewing Geometric Concepts
Areas_Improvement=Tatiana was able to use her intuition and skills to solve geometry problems
Action_Plan=I requested Tatiana to try a problem we did together on her own and see if she can reprodu
ce it independently
Comment=Tatiana was able to reason through problems on her own, with minimal assistance. This  was a s
uccessful session for that reason X_Test_Date=. X_Date_Pass=. _ERROR_=1 _N_=1

And:

 Mathematical operations could not be performed at the following places. The results of the
      operations have been set to missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      77 at 50:15   70 at 51:15

As mentioned, running the program only generates missing values for the new variable.  

 

I did run a PROC CONTENTS on the original data set and found that Session_Date does have a DATE9. informat, Test_Date and Date_Pass though have a $5. character informat.  A PROC PRINT shows that Session_Date returns a date such as 31OCT2016 whereas Test_Date & Date_Pass returns a converted date # like 43040.

 

This seems like running the INTCK function on character variables must be at the root of my issue but admittedly I'm not sure where to go from here to fix it.


Any help would be most appreciated!!!

Super User
Posts: 23,754

Re: Finding Average Time til Completion

Posted in reply to WinterCode

Your log will likely have errors as well. 

 

Convert your dates to SAS dates first, using INPUT() to create a variable with a numeric type and date format. 

Then you can do your calculations. Post back with any further issues. 

 

It would help if you provided some sample data (as text) with your code that could be tested, otherwise we’re guessing at best. 

And if there are errors/warnings in the log, include the full log. 

Ask a Question
Discussion stats
  • 1 reply
  • 43 views
  • 0 likes
  • 2 in conversation