/************************************************/ /* This data set examines number of foggy days */ /* annually from 1948 to 2003. The years 1963 */ /* to 1998 are missing. Station 13741 is */ /* located in Roanoke VA */ /************************************************/ /* Use range commands in proc format to convert */ /* a numeric variable to a factor. The same */ /* technique can be used to group character */ /* categories as well. */ proc format; value decadefmt 1948-<1950='1940s' 1950-1959='1950s' 1960-1969='1960s' 1970-1979='1970s' 1980-1989='1980s' 1990-1999='1990s' 2000-HIGH='2000s'; value fogfmt 0-20 = 'Low' 20-30 = 'Medium' 30-HIGH= 'High'; run; data agency13741; input year days; * Number of foggy days; /* Recording method changed in 1980 */ if year < 1980 then prepost=1; else prepost=2; datalines; 1948 45.24 1949 49 1950 37 1951 28 1952 22 1953 21 1954 18 1955 23 1956 27 1957 42 1958 24 1959 27 1960 23 1961 21 1962 24 1963 . 1964 . 1965 . 1966 . 1967 . 1968 . 1969 . 1970 . 1971 . 1972 . 1973 . 1974 . 1975 . 1976 . 1977 . 1978 . 1979 . 1980 . 1981 . 1982 . 1983 . 1984 . 1985 . 1986 . 1987 . 1988 . 1989 18 1990 10 1991 8 1992 18 1993 11 1994 5 1995 13 1996 31 1997 21 1998 16 1999 9.02 2000 17 2001 12 2002 8 2003 13 ; /* I was unable to suppress the default header and the labels */ /* are nested inside the variable names--not very attractive */ proc freq data=agency13741; title 'Decade by Fog Intensity'; label year='Decade' days='Intensity'; tables year*days/nopercent nocol; format year decadefmt. days fogfmt.; run; /* Here is a fix that modifies the underlying template borrowed from */ /* Customizing FREQ Procedure Output. We'll discuss PROC TEMPLATE later. */ */ proc template; define crosstabs Base.Freq.CrossTabFreqs; define header tableof; text "Table of " _row_label_ " by " _col_label_; end; define header rowsheader; text _row_label_ / _row_label_ ^= ' '; text _row_name_; end; define header colsheader; text _col_label_ / _col_label_ ^= ' '; text _col_name_; end; cols_header=colsheader; rows_header=rowsheader; header tableof; end; run; ods listing close; ods html file='body.html'; proc freq data=agency13741; title 'Decade by Fog Intensity'; label year='Decade' days='Intensity'; tables year*days/nopercent norow nocol; format year decadefmt. days fogfmt.; run;