1、o Double - double spaces the printed output.o Label - uses variable labels as column headings (variable name is default heading).o Noobs - suppresses the observation number in the output.Example 1 List containing all the variables and all the observations.data a; input year sales cost; profit=sales-
2、cost; cards;1981 12132 110211982 19823 129281983 16982 140021984 18432 14590;run;proc print data=a; title Simple PROC PRINT ReportExample 2 Removal of column OBS and impression limited to the first 5 observations.data exprev; input Region $ State $ Month monyy5. Expenses Revenues; format month monyy
3、5.; datalines;Southern GA JAN95 2000 8000Southern GA FEB95 1200 6000Southern FL FEB95 8500 11000Northern NY FEB95 3000 4000Northern NY MAR95 6000 5000Southern FL MAR95 9800 13500Northern MA MAR95 1500 1000proc print data=exprev(obs=5) noobs; var month state expenses;Monthly Expenses for Offices in E
4、ach StateExample 3 Instruction ID with not sorted observationsdata bid; input id age;987 65687 75254 55236 70proc print;Example 4 Instruction ID, after sorting of the observations.data bid2; input pat_id age;proc sort; by pat_id; *var pat_id; id pat_id;Example 5 Test of one or the other condition, i
5、nstruction WHEREdata bid3;proc print noobs; var age; where age 500 OR tot_vendor20000; SUM quantite tot_vendor;RUN;Example 7 Instructions SUM and BY statement data trim2;proc sort ; by vendor;PROC PRINT DATA=trim2 NOOBS;Summary by VenderExample 8 Instruction PAGEBY and SUMBYdata trim3;PROC PRINT DAT
6、A=trim3 NOOBS; SUMBY vendor; PAGEBY vendor;Pageby option controls page ejects that occur before a page is full.Sumby option limits the number of sums that appear in the report.Example 9 Options with Label, Double, Title and FootnotePROC PRINT DATA=trim5 NOOBS label double;Summary by Vendor FOOTNOTE
7、Results of Data-trim4 LABEL vendor = Vendor mois = Mois quantite = Quantity of Vendor tot_vendor = Total of VendorsThe FREQ procedure produces one-, two- , n-way (crosstabulation) frequency tables. The SAS procedure PROC FREQ is commonly used to produce summary data in tabular form. It can be used o
8、n either character or numeric data. Statistical analysis will be followed later. Seven examples are shown here using this procedure on freq_x dataset. The following is a summary of options and optional statements that can be used with PROC FREQ. Optional statements can be in any order, while options
9、 are entered at the end of the TABLES statement, following / and before Note that this list represents only a portion of all available to the user from SAS: TABLES - optional statement for specifying the variables to be included in the analysis. WEIGHT - optional statement for specifying the variabl
10、es to be summed for each value of the variables specified in the TABLES statement. MISSING - option to include missing values in the calculations within the table. MISSPRINT - option to display the missing values in the tables without including them in the calculations. LIST - option to list values
11、of variables side by side rather than in tabular form. OUT= - option to create a data set containing the output generated by the TABLES statement. There are some of options, Nofreq, Norow, Nocol, Nopercent et al.Syntax: PROC FREQ options;BY variables;TABLES requests WEIGHT variable;Example 1: simple
12、 outputdata freq_01; input name $ sex $ age height ;Allan M 25 174Ben M 23 176Christine F 24 164David M 32 174Edwards M 36 178Frank . 38 172Glory F 28 166Hill M 32 170Jack M 33 172Katy . 26 162Lily F 24 169Paula F . 163proc freq data=freq_01; title1 PROC FREQ: example 01 title2 No keywords specified
13、Example 2: One-way tableproc freq data=freq_02; tables sex age;1-way tables for sex and age specified by TABLES keywordExample 3: 2-way tablesproc freq data=freq_03; tables sex*age;two-way tables for sex and age specified by TABLES keywordExample 4: 2-way tables listing of the values of the variable
14、s side by sideproc freq data=freq_04; tables sex*age/list missing;two-way tables using list and missingExample 5: 3 way tablesproc freq data=freq_05; tables name*sex*age ;3 way table: height by weight, controlling for name /*The first variable represents the control variable*/;Example 6: Weight data
15、DATA freq_06 ; INPUT rater1 rater2 count;DATALINES;1 1 5 1 2 2 1 3 1 2 1 1 2 2 7 2 3 2 3 1 1 3 2 2 3 3 9 PROC FREQ DATA = freq_06 ; WEIGHT count; TABLE rater1*rater2 ; TITLE1 weighted dataExample 7: Out option tables age /out =freq_07; create new dataset using out optionExample 8: Missing / Missprin
16、t tables sex /missing ;/*misprint*/Example 9: NLEVELSinput agegrp sex $ ;1 F 1 F 1 M 2 M 2 M 3 F 3 F 3 Fproc freq data=a nlevels;tables sex*agegrp/noprint;This option in PROC FREQ statement is used to display the “Number of Variable Levels” . By using this options we can get the distinct count for e
17、ach variable listed in the TABLES statement. It is best to use NLEVELS and NNOPRINT options option to know the number of levels of variable before printing the frequency table if the data set is too large in size and if you unaware of what could be distinct count for each variable.Example 10: CROSSL
18、ISTdisplays crosstabulation tables in ODS column format. This option creates a table that has a table definition that you can customize by using the TEMPLATE procedure.tables sex*agegrp/crosslist;Warning: you cannot specify both the LIST option and the CROSSLIST option in the same TABLES statement.T
19、he CROSSLIST option looks the same as LIST option, but there are few differences as shown below.CROSSLIST LISTStatistics FREQUENCY FREQUENCYPERCENT PERCENTROW PERCENT CUMULATIVE FREQUENCYCOLUMN PERCENT CUMULATIVE PERCENTTotals Produces sub totals and final totals. No totalsRows with Display the vari
20、able levels with Suppress the variable levels withzero frequencies zero frequencieszero freqPROC MEANS only be performed on numeric data This procedure gives the following summary statistics (if no options are specified) for each variable listed in the VAR statement: number of observations, mean, standard deviation, minimum value, maximum value, and standard error of the mean. Options: You can select which statistics you want to have printed from the following list: N, NMISS (number of missing values), MEAN, STD, VAR, MIN, MAX, SKEWNESS, KURTOSIS, lclm and uclm options produ
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1