proc ttest data=single;
where Place IN('New York','Toronto');
the output that I get gives time in SAS time (for e.g. the Mean Time of New York is 8060). Is it possible to apply a format statement here so as to have time in format "hh:mm:ss" The data set "single" has the variable Time in this format, isnt it ideally true that when t test is applied on a variable from the dataset with time in a given format works for the t test as well.
If it does not work, then kindly could anyone suggest me where the format statement fits in Proc t test?
Have you tried a FORMAT statement in PROC TTEST??? Normally FORMAT used Inside a PROC step will cause the format to be used for the display of the variables listed. A FORMAT statement goes anywhere between the PROC statement and the RUN or QUIT statement.
The general use of the statement is:
format varname fmtname.; (for numeric vars)
format varname $fmtname.; (for char vars)
It should be easy to find a time format or a date/time format by searching on support.sas.com for the topic "formats by category"
there is one issue that is not very clear and that is if I use format in the Proc t test, given that i get mean values as well fior the analysis variable, is it possible to have these values in the time format as well, or does SAS treat the output of the Proc t test like the mean, standard deviation, min. & max. vlaues of the variable on w format is applied as different so that it is not possible to have these output in proper format.
For example, if I want to test if there is significant difference in the mean time between two different places , then is it possible to have the mean values in time format.
So if I use the code:--
proc ttest data=one;
where PLACE IN('New York','Toronto');
then the mean values that I get for the two places will not be in time format..
You said you wanted to apply a format to your CLASS variable. TIME is not your CLASS variable -- you have TIME on the VAR statement, so it is an ANALYSIS variable. I do not believe you can apply a format to the calculated statistics with a FORMAT statement.
The FORMAT statement in your code is incorrect if you want to apply a format to the CLASS variable. That syntax would be:
format PLACE $fmtname.;
You might want to read the documentation on working with DATE and DATETIME and TIME variables. It may not be appropriate to format all the calculated statistics with time formats, depending on what your dates/times represent -- as described in this Tech Support note: http://support.sas.com/techsup/technote/ts668.pdf
Since a time-based variable represents the number of seconds since midnight (or the number of seconds before or after midnight on Jan 1, 1960 if you have a DATE/TIME variable), you might want to pay special attention to the implications of this information from the above Tech Support document:
SAS times are a count of the number of seconds since midnight. They can and often do contain decimal values representing fractions of a second. The range of values is 0 <= sas time < 86400. A SAS time variable having a value of 60 is 1 minute after midnight. 12:00 noon would be stored internally as 43200. midnight is stored as 0. If a SAS time variable has a value larger than 86400, different formats treat the value differently.
It might be OK to format the calculated MIN and MAX with the TIME format, but it may or may not be appropriate to format the MEAN or STDDEV or STDERR with a TIME format.
One thing you can do is capture the output from PROC TTEST in a SAS dataset and then use PROC PRINT to print the numbers using the format that is most appropriate. The other alternative is to change the table template used for PROC TTEST -- this is probably the more complicated approach and would require a steep learning curve compared to PROC PRINT.
To save the output with MIN, MAX and MEAN from PROC TTEST, use the ODS OUTPUT statement. I believe the output object of interest is the STATISTICS output object. The program below shows how to create an output object from the TTEST procedure. The ODS TRACE statement puts output object information into the SAS log -- if the STATISTICS output object is not the one you want, then you can examine the other output objects using similar syntax, once you pick the output object name of interest.
ods trace on / label;
ods output statistics=work.tstat;
proc ttest data=one;
ods trace off;
proc contents data=work.tstat;
title 'What is in the Output dataset';
proc print data=work.tstat;
title 'Use the appropriate format here';
format mean minimum maximum time8.;
I agree with Cynthia that you have provided conflicting information regarding what you want to format. Presuming that you want to format the dependent variable, one way you can do that is by modifying the template.