sas 综合习题
sas测试题及答案
sas测试题及答案1. SAS中,如何将一个数据集的所有变量的值增加10?A. data dataset; set dataset; +10; run;B. data dataset; set dataset; +10; quit;C. data dataset; set dataset; +10; run;D. data dataset; set dataset; +10;答案:C2. 在SAS中,如何创建一个新的数据集,并将原数据集中的变量`Var1`和`Var2`复制到新数据集中?A. data new_dataset; set old_dataset; Var1 =old_dataset.Var1; Var2 = old_dataset.Var2; run;B. data new_dataset; set old_dataset; Var1 = Var1; Var2 = Var2; run;C. data new_dataset / old_dataset; set old_dataset; Var1 = old_dataset.Var1; Var2 = old_dataset.Var2; run;D. data new_dataset; set old_dataset; Var1 = Var1; Var2 = Var2; quit;答案:A3. SAS中,如何使用`proc print`步骤打印数据集的前10行?A. proc print data=dataset firstobs=10;B. proc print data=dataset firstobs=1 obs=10;C. proc print data=dataset firstobs=10;D. proc print data=dataset firstobs=1 obs=10;答案:B4. 在SAS中,如何使用`if-then`语句来创建一个新的变量`NewVar`,当`Var1`大于10时,`NewVar`的值为`Var1`的两倍,否则为0?A. data dataset; set dataset; if Var1 > 10 then NewVar = 2 * Var1; else NewVar = 0; run;B. data dataset; set dataset; if Var1 > 10 then NewVar = 2 * Var1; NewVar = 0; run;C. data dataset; set dataset; if Var1 > 10 NewVar = 2 *Var1; else NewVar = 0; run;D. data dataset; set dataset; if Var1 > 10 then NewVar = 2 * Var1; else NewVar = 0; quit;答案:A5. SAS中,如何使用`proc means`步骤计算数据集中`Var1`的平均值?A. proc means data=dataset N mean of Var1;B. proc means data=dataset N mean Var1;C. proc means data=dataset N=mean Var1;D. proc means data=dataset N mean Var1;答案:D结束语:以上是SAS测试题及答案,希望能够帮助您更好地理解和掌握SAS编程的基础知识。
sas期末考试试题
sas期末考试试题SAS期末考试试题一、选择题(每题2分,共20分)1. 在SAS中,以下哪个命令用于创建数据集?A. PROC SORTB. DATASETSC. SETD. INPUT2. 下列哪个选项不是SAS数据集中的变量属性?A. 长度B. 格式C. 标签D. 颜色3. SAS中的PROC FREQ过程用于:A. 描述性统计分析B. 频率分布分析C. 回归分析D. 时间序列分析4. 以下哪个命令用于在SAS中生成随机数?A. RANDB. RANDOMC. RNDD. UNIVARIATE5. 在SAS中,如何使用PROC GPLOT创建图形?A. 使用PLOT语句B. 使用SGPLOT过程C. 使用GPLOT语句D. 使用GRAPH语句二、简答题(每题10分,共30分)1. 解释SAS中的宏语言及其用途。
2. 描述如何使用SAS进行数据清洗的基本步骤。
3. 简述SAS中PROC UNIVARIATE过程的功能和应用场景。
三、编程题(每题25分,共50分)1. 编写SAS程序,从一个名为“sales_data”的数据集中提取出所有销售额超过平均销售额的产品,并计算这些产品的总销售额。
```sasdata sales_data;set sales_data;if sales > mean(sales);run;proc means data=sales_data mean;var sales;output out=avg_sales mean=avg_sales;run;data top_sales;set sales_data;where sales > avg_sales.avg_sales;run;proc sql;select sum(sales) into: total_salesfrom top_sales;quit;```2. 编写SAS程序,使用PROC REG过程对一个名为“education_data”的数据集进行线性回归分析,预测学生的考试成绩(变量名为“score”)基于其学习时间(变量名为“study_hours”)。
sas试题A
考生注意:舞弊万莫做,那样要退学,自爱当守诺,最怕错上错,若真不及格,努力下次过。
开 试题成绩课程名称 应用统计软件(A ) 考试时间 年 11月19日8时 00分至10时 00分 教 研 室 统计 开卷 闭卷 适用专业班级 统计061 提前 期末 班 级 姓名 学号一、填空题(每空1分,共20分):1.SAS 的三个基本窗口是 , 及 。
2.SAS 程序每一数据步以 开始,而过程步以 开始,整个程序以 语句结束。
3.每个语句常以开始的关键词称呼,用 表示语句的结束。
4.运行存在错误的程序后,在 窗口中会出现红色错误提示;可通过按 键或在命令栏中发布 命令或从 菜单中选Recall Last Submit ,将程序重新调入PGM 窗口进行修改。
5.调用SAS/INSIGHT 可在命令行中键入命令 。
6.SAS/INSIGHT 的功能主要有:通过多窗口连动的图象和分析结果,对数据进行探索;分析 分布;用 和 研究多变量间的关系;用 和 说明、拟合变量间关系的模型。
7.调用分析员应用可在命令行中键入命令 。
8.分析员通过选择 的不同选项可完成各种基本分析功能和绘图功能;完成每项任务后,能立即显示相应的结果,而且保留相应的 ;在分析过程中可随时调出有关的图形和结果进行显示。
----------------------------------------------------------------------装--------------------订--------------------线-------------------------------------------------------------试 题 共 3 页 第 1 页run;A. d:\B. d:\sasdataC.c:\D.不确定 4.下列程序读入外部文件的模式是( )Data dst; Infile 'd:\lecsas\basev8\dst\imptdt01.dat' firstobs=2 obs=3; Input ID Age Actlevel $ Sex $; Run;A. 按列输入模式B.格式化输入模式C.列举输入模式D.其它模式 5.列举模式读入分隔符缺省为( )A.Tab 键B.逗号C.空格符D.任意符号都可以 6.提交下列SAS 程序,那种说法是正确的( )proc sort data = work.test; by fname descending salary; run;A. 数据集work.test 先按照fname 降序排列,再按照salary 降序排列B. 数据集work.test 先按照fname 升序排列,再按照salary 降序排列C. 数据集work.test 先按照salary 降序排列,再按照fname 降序排列D. 数据集work.test 先按照salary 降序排列,再按照fname 升序排列 7.提交下列程序,得到的回归方程为( ) data tem; set sasuser. admit; a2=age*age; a3=a2*age;a4=a3*age;run;proc glm data=tem;model fee=age a2 a3 a4/ss1; run;A .fee=age+b1*age 2+b2*age 3+b3*age 4命题负责人: 教研室主任:。
SAS认证考试(官方练习题集和校正答案)
1. A raw data file is listedbelow.The following program issubmitted using this file asinput:data work.family;infile 'file-specification';<insert INPUTstatement here>run;Which INPUT statementcorrectly reads the values forthe variable Birthdate asSAS date values?a.input relation$ first_name$ birthdate date9.;b.input relation$ first_name$ birthdatemmddyy8.;c.input relation$ first_name$ birthdate :date9.;d.input relation$ first_name$ birthdate :mmddyy8.;Correct answer: dAn informat is used to translate the calendar date to a SAS datevalue. The date values are in the form of two-digit values formonth-day-year, so the MMDDYY8. informat must be used.When using an informat with list input, the colon-formatmodifier is required to correctly associate the informat with thevariable name.You can learn about•informats in Reading Date and Time Values•the colon-format modifier in Reading Free-FormatData.2. A raw data file is listed below.1---+----10---+----20---+---Jose,47,210Sue,,108The following SAS program is submitted using the raw data fileabove as input:data employeestats;<insert INFILE statement here>input name $ age weight;run;The following output is desired:name age weightJose47210Sue.108Which of the following INFILE statements completes theprogram and accesses the data correctly?a.infile 'file-specification' pad;b.infile 'file-specification' dsd;c.infile 'file-specification' dlm=',';d.infile 'file-specification' missover;Correct answer: bThe PAD option specifies that SAS pad variable length recordswith blanks. The MISSOVER option prevents SAS fromreading past the end of the line when reading free formatteddata. The DLM= option specifies the comma as the delimiter;however, consecutive delimiters are treated as one by default.The DSD option correctly reads the data with commas asdelimiters and two consecutive commas indicating a missingvalue like those in this raw data file.You can learn about•the PAD option in Reading Raw Data in Fixed Fields•the MISSOVER option in Creating MultipleObservations from a Single Record•the DLM= option and the DSD option in Reading Free-Format Data.3. The following program is submitted:data numrecords;infile cards dlm=',';input agent1 $ agent2 $ agent3 $;cards;jones,,brownjones,spencer,brown;run;What is the value for the variable named Agent2 in the secondobservation?a.Brownb.Spencerc.' ' (missing character value)d.There is no value because only one observation iscreated.Correct answer: dThe CARDS statement enables you to read instream data. Anynumber of consecutive commas are considered to be a singledelimiter as a result of the DLM= option, and the length of eachvariable defaults to 8 bytes. Therefore, the values jones,brownjon, and spencer are assigned to Agent1, Agent2, andAgent3, respectively, for the first observation. The rest of thedata on the record is not read by the INPUT statement and is notoutput to the data set.You can learn about•the CARDS statement in Creating SAS Data Sets fromRaw Data•the default length of variables in Reading Free-FormatData.4. A raw data file is listed below.1---+----10---+----20---+----30---+----40---+----50TWOSTORY 1040 2 1SANDERS ROAD $55,850CONDO 2150 4 2.5JEANS AVENUE $127,150The following program is submitted using this file as input:data work.houses;infile 'file-specification';<insert INPUT statement here>run;Which one of the following INPUT statements reads the rawdata file correctly?a.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street 16.@40 price dollar8;b.input @1 style $8+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16@40 price dollar8.;c.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16.@40 price dollar8.;d.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3street 16.@40 price dollar8.;Correct answer: cFormatted input requires periods as part of the informat name.The period is missing from the variables Style and Street inAnswer b, the variable Baths in Answer d, and the variablePrice in Answer a (which is also missing a dollar sign to readthe variable Street as a character value).You can learn about formatted input and informats in ReadingRaw Data in Fixed Fields.5. The following SAS program is submitted at the start of a newSAS session:libname sasdata 'SAS-data-library';data sasdata.sales;set sasdata.salesdata;profit=expenses-revenues;run;proc print data=sales;run;The SAS data set Sasdata.Salesdata has ten observations.Which one of the following explains why a report fails togenerate?a.The DATA step fails execution.b.The SAS data set Sales does not exist.c.The SAS data set Sales has no observations.d.The PRINT procedure contains a syntax error.Correct answer: bThe DATA step creates a permanent SAS data set,Sasdata.Salesdata. The PRINT procedure is printing atemporary SAS data set, Sales, that is stored in the Worklibrary. At the beginning of the SAS session, Work.Sales doesnot exist.You can learn about•creating permanent data sets with the DATA step inCreating SAS Data Sets from Raw Data•temporary data sets in Basic Concepts.6. Which action assigns a reference named SALES to a permanentSAS data library?a.Issuing the command:libref SALES 'SAS-data-library'b.Issuing the command:libname SALES 'SAS-data-library'c.Submitting the statement:libref SALES 'SAS-data-library';d.Submitting the statement:libname SALES 'SAS-data-library';Correct answer: dThe LIBNAME statement assigns a reference known as a librefto a permanent SAS data library. The LIBNAME commandopens the LIBNAME window.You can learn about the LIBNAME statement in ReferencingFiles and Setting Options.7. The following SAS program is submitted:data newstaff;set staff;<insert WHERE statement here>run;Which one of the following WHERE statements completes theprogram and selects only observations with a Hire_date ofFebruary 23, 2000?a.where hire_date='23feb2000'd;b.where hire_date='23feb2000';c.where hire_date='02/23/2000'd;d.where hire_date='02/23/2000';Correct answer: aA SAS date constant must take the form of one- or two-digitday, three-digit month, and two- or four-digit year, enclosed inquotation marks and followed by a d ('ddmmmyy<yy>'d).You can learn about SAS date constants in Creating SAS DataSets from Raw Data.8. Which one of the following SAS date formats displays the SASdate value for January 16, 2002 in the form of 16/01/2002?a.DATE10.b.DDMMYY10.c.WEEKDATE10.d.DDMMYYYY10.Correct answer: bThe requested output is in day-month-year order and is 10 byteslong, so DDMMYY10. is the correct format. AlthoughWEEKDATE10. is a valid SAS format, it does not display theSAS date value as shown in the question above.DDMMYYYY10. is not a valid SAS date format, and theDATE w. format cannot accept a length of 10.You can learn about•the DDMMYY10. format in Creating List Reports•the WEEKDATE10. format in Reading Date and TimeValues.9. Which one of the following displays the contents of an externalfile from within a SAS session?a.the LIST procedureb.the PRINT procedurec.the FSLIST procedured.the VIEWTABLE windowCorrect answer: cThe PRINT procedure and VIEWTABLE window display thevalues in SAS data sets. The FSLIST procedure displays thevalues in external files. There is no LIST procedure in SAS.You can learn about•the PRINT procedure in Creating List Reports•the VIEWTABLE window in Referencing Files andSetting Options.10. The SAS data set Sashelp.Prdsale contains the variablesRegion and Salary with 4 observations per Region.Sashelp.Prdsale is sorted primarily by Region and withinRegion by Salary in descending order.The following program is submitted:data one;set sashelp.prdsale;retain temp;by region descending salary;if first.region thendo;temp=salary;output;end;if last.region thendo;range=salary-temp;output;end;run;For each region, what is the number of observation(s) written tothe output data set?a.0b.1c. 2d.4Correct answer: cThe expression first.region is true once for each regiongroup. The expression last.region is true once for each regiongroup. Therefore, each OUTPUT statement executes once for atotal of 2 observations in the output data set.You can learn about the FIRST.variable expression and theOUTPUT statement in Reading SAS Data Sets.11. The following SAS program is submitted:proc contents data=sasuser.houses;run;The exhibit below contains partial output produced by theCONTENTS procedure.Data Set Name SASUSER.HOUSES Observations15Member Type DATA Variables6Engine V9Indexes0Created Tuesday, April 22,2003 03:09:25 PMObservationLength56Last Modified Tuesday, April 22,2003 03:09:25 PMDeletedObservationsProtection Compressed NO Data Set Type Sorted NOLabel Residential housing for saleDataRepresentationWINDOWS_32Encoding wlatin1 Western (Windows)Which of the following describes the Sasuser.Houses data set?a.The data set is sorted but not indexed.b.The data set is both sorted and indexed.c.The data set is not sorted but is indexed.d.The data set is neither sorted nor indexed.Correct answer: dThe exhibit above shows partial output from the CONTENTSprocedure, In the top right-hand column of the output, you seethat Indexes has a value of 0, which indicates that no indexesexist for this data set. Also, Sorted has a value of NO, whichindicates that the data is not sorted.You can learn about the CONTENTS procedure in ReferencingFiles and Setting Options.12. The following SAS program is submitted:proc sort data=work.test;by fname descending salary;run;Which one of the following represents how the observations aresorted?a.The data set Work.Test is stored in ascending order byboth Fname and Salary values.b.The data set Work.Test is stored in descending order byboth Fname and Salary values.c.The data set Work.Test is stored in descending order byFname and ascending order by Salary values.d.The data set Work.Test is stored in ascending order byFname and in descending order by Salary values.Correct answer: dThe DESCENDING keyword is placed before the variable nameit modifies in the BY statement, so the correct description is indescending order by Salary value within ascending Fnamevalues.You can learn about the SORT procedure and theDESCENDING keyword in Creating List Reports.13. The following SAS program is submitted:data names;title='EDU';if title='EDU' thenDivision='Education';else if title='HR' thenDivision='Human Resources';else Division='Unknown';run;Which one of the following represents the value of the variableDivision in the output data set?catiocationc.Human Red.Human ResourcesCorrect answer: bThe length of the variable Division is set to 9 when the DATAstep compiles. Since the value of the variable Title is EDU, thefirst IF condition is true; therefore, the value of the variableDivision is Education.You can learn about•the length of a variable in Understanding DATA StepProcessing•IF-THEN statements in Creating and ManagingVariables.14. Which one of the following SAS programs creates a variablenamed City with a value of Chicago?a.data work.airports;AirportCode='ord';if AirportCode='ORD' City='Chicago';run;b.data work.airports;AirportCode='ORD';if AirportCode='ORD' City='Chicago';run;c.data work.airports;AirportCode='ORD';if AirportCode='ORD' then City='Chicago';run;d.data work.airports;AirportCode='ORD';if AirportCode='ORD';then City='Chicago';run;Correct answer: cThe correct syntax for an IF-THEN statement is: IF expressionTHEN statement;In this example, the variable City is assigned a value ofChicago only if the expression AirportCode='ORD' is true.You can learn about IF-THEN statements in Creating andManaging Variables.15. The following SAS program is submitted:data work.building;code='DAL523';code='SANFRAN604';code='HOUS731';length code $ 20;run;Which one of the following is the length of the code variable?a.6b.7c.10d.20Correct answer: aThe DATA step first goes through a compilation phase, then anexecution phase. The length of a variable is set during thecompilation phase and is based on the first time the variable isencountered. In this case, the variable code is set to the lengthof the text string DAL523 which is 6 characters long. The nextassignment statements are ignored during compilation. TheLENGTH statement is also ignored since the length has alreadybeen established, but a note will be written to the log.You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•the LENGTH statement in Creating and ManagingVariables.16. Which of the following statements creates a numeric variablenamed IDnumber with a value of 4198?a.IDnumber=4198;b.IDnumber='4198';c.length IDnumber=8;d.length IDnumber $ 8;Correct answer: aThe first reference to the SAS variable in the DATA step setsthe name, type, and length of the variable in the program datavector (PDV) and in the output SAS data set. The assignmentstatement IDnumber=4198; is the first reference and creates anumeric variable named IDnumber with a default storage lengthof 8 bytes.You can learn about•creating variables in the DATA step in UnderstandingDATA Step Processing•numeric variables in Basic Concepts.17. The following program is submitted:data fltaten;input jobcode $ salary name $;cards;FLAT1 70000 BobFLAT2 60000 JoeFLAT3 30000 Ann;run;data desc;set fltaten;if salary>60000 then description='Over 60';else description='Under 60';run;What is value of the variable named description when thevalue for salary is 30000?a.Under 6b.Under 60c.Over 60d.' ' (missing character value)Correct answer: aThe variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrenceof the variable description is on the IF statement, and since itis assigned the value Over 60, the length of the variable is 7.Therefore, for the salary value of 30000, description has thevalue of Under 6 (the 0 is truncated.)You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•IF-THEN/ELSE statements in Creating and ManagingVariables.18. A raw data file is listed below.1---+----10---+----20---+---102320The following program is submitted:data all_sales;infile 'file-specification';input receipts;<insert statement(s) here>run;Which statement(s) complete(s) the program and produce(s) arunning total of the Receipts variable?a.total+receipts;b.total 0;sum total;c.total=total+receipts;d.total=sum(total,receipts);Correct answer: aThe SUM function and the assignment statement do not retainvalues across iterations of the DATA step. The sum statementtotal+receipts; initializes total to 0, ignores missing valuesof receipt, retains the value of total from one iteration to thenext, and adds the value of receipts to total.You can learn about the sum statement in Creating andManaging Variables.19. A raw data file is listed below.1---+----10---+----20---+---1901 21905 11910 61925 11941 1The following SAS program is submitted and references the rawdata file above:data money;infile 'file-specification';input year quantity;total=total+quantity;What is the value of total when the data step finishesexecuting?a.0b.1c.11d. . (missing numeric value)Correct answer: dThe variable Total is assigned a missing value during thecompilation phase of the DATA step. When the first record isread in, SAS processes: total=.+2; which results in a missingvalue. Therefore the variable Total remains missing for allobservations.You can learn about•the compilation phase of the DATA step inUnderstanding DATA Step Processing•using missing values with arithmetic operators inCreating SAS Data Sets from Raw Data.20. The following program is submitted:data test;average=mean(6,4,.,2);run;What is the value of average?a.0b.3c.4d. . (missing numeric value)Correct answer: cThe MEAN function adds all of the non-missing values anddivides by the number of non-missing values. In this case, 6 + 4+ 2 divided by 3 is 4.You can learn about the MEAN function in Transforming Datawith SAS Functions.21. The following SAS program is submitted:data work.AreaCodes;Phonenumber=3125551212;Code='('!!substr(Phonenumber,1,3)!!')';run;Which one of the following is the value of the variable Code inthe output data set?a.( 3)b.(312)c.3d.312Correct answer: aAn automatic data conversion is performed whenever a numericvariable is used where SAS expects a character value. Thenumeric variable is written with the BEST12. format and theresulting character value is right-aligned when the conversionoccurs. In this example, the value of Phonenumber is convertedto character and right-aligned before the SUBSTR function isperformed. Since there are only 10 digits in the value ofPhonenumber, the right-aligned value begins with two blanks.Therefore the SUBSTR function picks up two blanks and a 3,and uses the BEST12. format to assign that value to Code. Then,the parentheses are concatenated before and after the two blanksand a 3.You can learn about automatic data conversion and theSUBSTR function in Transforming Data with SAS Functions.22. The following SAS program is submitted:data work.inventory;products=7;do until (products gt 6);products+1;end;run;Which one of the following is the value of the variableproducts in the output data set?a.5b.6c.7d.8Correct answer: dA DO UNTIL loop always executes at least once because thecondition is not evaluated until the bottom of the loop. In theSAS program above, the value of Products is incremented from7 to 8 on the first iteration of the DO UNTIL loop, before thecondition is checked. Therefore the value of Products is 8.You can learn about DO UNTIL loops in Generating Datawith DO Loops.23. The following program is submitted:data work.test;set work.staff (keep=salary1 salary2 salary3);<insert ARRAY statement here>run;Which ARRAY statement completes the program and createsnew variables?a.array salary{3};b.array new_salary{3};c.array salary{3} salary1-salary3;d.array new_salary{3} salary1-salary3;Correct answer: bAlthough each of the ARRAY statements listed above is a validstatement, only Answer B creates new variables namednew_salary1, new_salary2 and new_salary3. Answer C andAnswer D both create an array that groups the existing data setvariables salary1, salary2, and salary3. Since the array inAnswer A is named salary, it also uses the existing data setvariables.You can learn about creating new variables in an ARRAYstatement in Processing Variables with Arrays.24. Which of the following permanently associates a format with avariable?a.the FORMAT procedureb.a FORMAT statement in a DATA stepc.an INPUT function with format modifiersd.an INPUT statement with formatted style inputCorrect answer: bTo permanently associate a format with a variable, you use theFORMAT statement in a DATA step. You can use theFORMAT procedure to create a user-defined format. You usethe INPUT function to convert character data values to numericvalues with an informat. You use the INPUT statement to readdata into a data set with an informat.You can learn about•permanently assigning a format to a variable in Creatingand Managing Variables•the FORMAT statement in Creating List Reports•the FORMAT procedure in Creating and ApplyingUser-Defined Formats•the INPUT function in Transforming Data with SASFunctions•the INPUT statement in Reading Raw Data in FixedFields.25. The following report is generated:Which of the following steps created the report?a.proc freq data=sasuser.houses;tables style price /nocum;format price dollar10.;label style="Style of homes"price="Asking price";run;b.proc print data=sasuser.houses;class style;var price;table style,n price*mean*f=dollar10.;label style="Style of homes"price="Asking price";run;c.proc means data=sasuser.houses n mean;class style;var price;format price dollar10.;label style="Style of homes"price="Asking price";run;d.proc report data=sasuser.houses nowd headline;column style n price;define style / group "Style of homes";define price / mean format=dollar8."Asking price";run;Correct answer: dThe FREQ procedure cannot create the average asking price.The CLASS statement and the VAR statement are not valid foruse with the PRINT procedure. The MEANS procedure outputwould have both the N statistic and the N Obs statistic since aCLASS statement is used. The REPORT procedure producedYou can learn about•the FREQ procedure in Producing DescriptiveStatistics•the PRINT procedure in Creating List Reports•the MEANS procedure in Producing DescriptiveStatistics•the REPORT procedure in Creating Enhanced List andSummary Reports.26. A SAS report currently flows over two pages because it is toolong to fit within the specified display dimension. Which one ofthe following actions would change the display dimension sothat the report fits on one page?a.Increase the value of the LINENO option.b.Decrease the value of the PAGENO option.c.Decrease the value of the LINESIZE option.d.Increase the value of the PAGESIZE option.Correct answer: dThe PAGESIZE= SAS system option controls the number oflines that compose a page of SAS procedure output. Byincreasing the number of lines available per page, the reportmight fit on one page.You can learn about the PAGESIZE= option in ReferencingFiles and Setting Options.27. Which one of the following SAS REPORT procedure optionscontrols how column headings are displayed over multiplelines?a.SPACE=BEL=d.BREAK=Correct answer: bThe SPLIT= option specifies how to split column headings. TheSPACE=, LABEL= and BREAK= options are not valid optionsin PROC REPORT.You can learn about the SPLIT= option for the REPORTprocedure in Creating Enhanced List and Summary Reports.28. The following SAS program is submitted:ods html file='newfile.html';proc print data=sasuser.houses;run;proc means data=sasuser.houses;run;proc freq data=sasuser.shoes;run;ods html close;proc print data=sasuser.shoes;run;How many HTML files are created?a.1b.2c. 3d.4Correct answer: aBy default, one HTML file is created for each FILE= option orBODY= option in the ODS HTML statement. The ODS HTMLCLOSE statement closes the open HTML file and ends theoutput capture. The Newfile.html file contains the output fromthe PRINT, MEANS, and FREQ procedures.You can learn about the ODS HTML statement in ProducingHTML Output.29. A frequency report of the variable Jobcode in the Work.Actorsdata set is listed below.Jobcode Frequency Percent CumulativeFrequencyCumulativePercentActor I233.33233.33 Actor II233.33466.67 Actor III233.336100.00Frequency Missing = 1The following SAS program is submitted:data work.joblevels;set work.actors;if jobcode in ('Actor I', 'Actor II') thenjoblevel='Beginner';if jobcode='Actor III' thenjoblevel='Advanced';else joblevel='Unknown';run;Which of the following represents the possible values for the variable joblevel in the Work.Joblevels data set?a.Advanced and Unknown onlyb.Beginner and Advanced onlyc.Beginner, Advanced, and Unknownd.' ' (missing character value)Correct answer: aThe DATA step will continue to process those observations that satisfy the condition in the first IF statement Although Joblevel might be set to Beginner for one or more observations, the condition on the second IF statement willevaluate as false, and the ELSE statement will execute and overwrite the value of Joblevel as Unknown.You can learn about•the IF statement in Creating SAS Data Sets from RawData•the ELSE statement in Creating and ManagingVariables.30. The descriptor and data portions of the Work.Salaries data setare shown below.Variable Type Len Posname Char80salary Char816status Char88name status salaryLiz S15,600Herman S26,700Marty S35,000The following SAS program is submitted:proc print data=work.salaries;where salary<20000;run;What is displayed in the SAS log after the program is executed?a.A NOTE indicating that 1 observation is read.b.A NOTE indicating that 0 observations were read.c.A WARNING indicating that character values have beenconverted to numeric values.d.An ERROR indicating that the WHERE clause operatorrequires compatible variables.Correct answer: dSalary is defined as a character variable. Therefore, the valuein the WHERE statement must be the character value 20,000enclosed in quotation marks.You can learn about the WHERE statement in Creating ListReports.31. Which of the following statements is true when SAS encountersa syntax error in a DATA step?a.The SAS log contains an explanation of the error.b.The DATA step continues to execute and the resultingdata set is complete.c.The DATA step stops executing at the point of the errorand the resulting data set contains observations up to thatpoint.d.A note appears in the SAS log indicating that theincorrect statement was saved to a SAS data set forfurther examination.Correct answer: aSAS scans the DATA step for syntax errors during thecompilation phase. If there are syntax errors, those errors getwritten to the log. Most syntax errors prevent further processingof the DATA step.You can learn about how SAS handles syntax errors in theDATA step in Understanding DATA Step Processing.32. Which TITLE statement would display JANE'S DOG as the textof the title?a.title "JANE"S DOG";b.title 'JANE"S DOG';c.title "JANE'S DOG";d.title 'JANE' ' 'S DOG';Correct answer: c。
“SSS”“SAS”判定三角形全等综合练习
证明:∵∠BAE=∠CAD, ∴∠BAE+∠BAD=∠CAD+∠BAD,
即∠DAE=∠CAB.
在△ADE 和△ACB 中,
AD=AC, ∠DAE=∠CAB, AE=AB, ∴△ADE≌△ACB(SAS). ∴DE=CB.
5.(2019·陕西)如图,点 A,E,F,B 在直线 l 上,AE=BF, AC∥BD,且 AC=BD.求证:CF=DE.
证明:在△ABD 和△ACE 中,
AB=AC, AD=AE, BD=CE,
∴△ABD≌△ACE(SSS). ∴∠BAD=∠1,∠ABD=∠2.
∵∠3=∠BAD+∠ABD, ∴∠3=∠1+∠2.
拓展提升
3.如图,已知CA=CB,AD=BD, M,N分别是CA,CB的中点, 求证:DM=DN.
证明:连接CD,如图所示. 在△CAD与△CBD中, CA=CB (已知),
9.(2020·宜宾)如图,在△ABC 中,点 D 是边 BC 的中点, 连接 AD 并延长到点 E,使 DE=AD,连接 CE.
(1)求证:△ABD≌△ECD; (2)若△ABD 的面积为 5,求△ACE 的面积.
解:(1)证明:∵D 是 BC 中点, ∴BD=CD. 在△ABD 和△ECD 中,
BC=EF, ∠ACB=∠DFE, CF=FC, ∴△BCF≌△EFC(SAS). ∴∠CBF=∠FEC.
03 综合题
11.已知在△ABC 和△ADE 中,AB=AC,AD=AE,∠BAC =∠DAE=90°.
(1)如图 1,当点 D 在 AC 上时,线段 BD,CE 有怎样的数量 关系和位置关系?直接写出你的结论;
(1)△ABC≌△DEF; (2)∠CBF=∠FEC.
证明:(1)∵AF=CD, ∴AF+FC=CD+FC, 即 AC=DF. ∵AB∥DE, ∴∠A=∠D. 在△ABC 和△DEF 中,
SAS综合练习题的(答案)
SAS金融数据处理综合练习题1.创建一包含10000个变量(X1-X10000),100个观测值的SAS数据集。
分别用DATA步,DATA步数组语句和IML过程实现。
(1)用data步实现data test1a;informat x1-x10000 9.2; /*创建100个变量,规定输出格*/do i=1to100; /*做循环*/output;/*每一次循环,输出所有的变量,包括i*/drop i;/*去掉i*/end;run;或者data test1a;format x1-x10000 best12.; /*创建10000个变量x1-x10000,但未有初始化*/do i=1to100; /*创建100个观测*/output;/*且每一个观测都输出到数据集test1a*/end;drop i;run;(2)用data步数组语句实现data test1b;array t{10000} x1-x10000 ;/*创建数组变量*/do i =1to100;/*每个变量有100个观测*/output;/*每一次循环,输出所有的变量,包括i*/drop i;/*去掉i*/end;/*循环结束*/data test1c;array t{10000} x1-x10000;do j=1to100;/*100次观测的循环*/do i = 1to10000;t{i}=i;/*第i个变量等于i*/end;output;/*输出第i次观测的i个变量的值*/end;drop i j;/*去掉i和j*/run;或者data test1b;array t{10000} x1-x10000;do j=1to100;/*100次观测的循环*/do i = 1to10000;t{i}=i;/*第i个变量等于i*/end;output;/*输出第i次观测的i个变量的值*/end;drop i j;/*去掉i和j*/run;(3)用IML过程实现proc iml;/*启用iml环境*/x='x1':'x10000';/*定义数组x1-x10000*/t= j(100,10000,1) ;/*创建100行10000列的. 同元素矩阵*/print t x;/*打印两个矩阵察看*/create test1d from t[colname=x];/*创建数据集c,变量数为列数,观测数为行数,列名更改为变量名,默认逻辑库为临时*/append from t; /*将t中的值填充的数据集中*/show datasets;show contents;/*显示数据集的一些7788的属性*/close test1d;run;quit;或者proc iml;x='x1':'x10000';t= shape(1,100,10000) ;/*shape和j不太一样,顺序是元素,行,列,j的顺序为行,列,元素*/print t x;create test1d from t[colname=x];append from t;show datasets;show contents;close test1d;run;quit;(4)用宏实现%macro names(name,number,obs);data a;%do i=1%to &obs;%do n=1%to &number;&name&n=1;%end;output;%end;run;%mend names;%names(x, 10000,100);2.多种方法创建包含变量X的10000个观测值的SAS数据集。
数学sas练习题
数学sas练习题(正文部分)1. 题目:求多项式的和与差题目描述:已知多项式P(x) = 3x^2 + 2x - 5和Q(x) = 2x^2 - 4x + 1,请计算P(x) + Q(x)和P(x) - Q(x)的结果。
解法:首先,将P(x) + Q(x)的每一项按照指数的大小排列,得出: P(x) + Q(x) = (3x^2 + 2x - 5) + (2x^2 - 4x + 1)= (3x^2 + 2x^2) + (2x - 4x) + (-5 + 1)= 5x^2 - 2x - 4接下来,计算P(x) - Q(x)的结果:P(x) - Q(x) = (3x^2 + 2x - 5) - (2x^2 - 4x + 1)= (3x^2 - 2x^2) + (2x + 4x) + (-5 - 1)= x^2 + 6x - 6因此,P(x) + Q(x)的结果为5x^2 - 2x - 4,而P(x) - Q(x)的结果为x^2 + 6x - 6。
2. 题目:解方程题目描述:求解方程2x + 5 = 13。
解法:将2x + 5 = 13进行变形,得到:2x = 13 - 52x = 8再将方程两边都除以2,得到:x = 8 / 2x = 4因此,方程2x + 5 = 13的解为x = 4。
3. 题目:计算三角形的面积题目描述:已知三角形的底边长为5cm,高为8cm,请计算三角形的面积。
解法:三角形的面积可以通过底边长和高的乘积再除以2来计算。
代入已知的数值,得到:面积 = (5 * 8) / 2= 40 / 2= 20因此,三角形的面积为20平方厘米。
4. 题目:计算等差数列的和题目描述:已知等差数列的首项为3,公差为4,求前10项的和。
解法:等差数列的和可以通过首项、末项和项数来计算。
首先,根据等差数列的性质,求得第10项的数值为:a10 = a1 + (10 - 1) * d= 3 + (10 - 1) * 4= 3 + 9 * 4= 3 + 36= 39接下来,使用等差数列的求和公式,计算前10项的和:S10 = (a1 + a10) * n / 2= (3 + 39) * 10 / 2= 42 * 10 / 2= 420 / 2= 210因此,等差数列前10项的和为210。
SAS上机练习试题[全部,含参考答案解析]
重庆医科大学--卫生统计学统计软件包SAS上机练习题(一)1、SAS常用的窗口有哪三个?请在三个基本窗口之间切换并记住这些命令或功能键。
2、请在PGM窗口中输入如下几行程序,提交系统执行,并查看OUTPUT窗和LOG窗中内容,注意不同颜色的含义;并根据日志窗中的信息修改完善程序。
3、将第2题的程序、结果及日志保存到磁盘。
4、试根据如下例1的程序完成后面的问题:表1 某班16名学生3门功课成绩表如下问题:1)建立数据集;2)打印至少有1门功课不及格同学的信息;(提示,使用if语句)参考程序:data a;input id sh wl bl;cards;083 68 71 65084 74 61 68085 73 75 46086 79 80 79087 75 71 68084 85 85 87085 78 79 75086 80 76 79087 85 80 82088 77 71 75089 67 73 71080 75 81 70118 70 54 75083 70 66 84084 62 73 65099 82 70 79;run;data b;set a;if sh<60 or wl<60 or bl<60then output;run;proc print data=b;var id sh wl bl;run;5、根据下列数据建立数据集表2 销售数据开始时间终止时间费用2005/04/28 25MAY2009 $123,345,0002005 09 18 05OCT2009 $33,234,5002007/08/12 22SEP2009 $345,60020040508 30JUN2009 $432,334,500提示:(格式化输入;数据之间以空格分隔,数据对齐;注意格式后面的长度应以前一个位置结束开始计算,如果读入错误,可试着调整格式的宽度;显示日期需要使用输出格式)开始时间,输入格式yymmdd10.终止时间,输入格式date10.费用,输入格式dollar12.参考程序:data a;input x1 yymmdd10. x2 date10. x3 dollar13.;cards;2005/04/28 25MAY2009 $123,345,0002005 09 18 05OCT2009 $33,234,5002007/08/12 22SEP2009 $345,60020040508 30JUN2009 $432,334,500;run;proc print;run;proc print;format x1 yymmdd10. x2 date9. x3 dollar13.;run;6、手机号码一编码规则一般是:YYY-XXXX-ZZZZ,其YYY为号段;XXXX一般为所在地区编码;ZZZZ为对应的个人识别编号。
统计软件sas期末考试试题及答案
统计软件sas期末考试试题及答案统计软件SAS期末考试试题一、选择题(每题2分,共20分)1. SAS软件的全称是什么?A. Statistical Analysis SystemB. System Analysis SystemC. System Analysis SoftwareD. Statistical Analysis Software2. 在SAS中,以下哪个命令用于数据集的排序?A. PROC SORTB. PROC MEANSC. PROC FREQD. PROC UNIVARIATE3. 数据集在SAS中通常存储在什么格式的文件中?A. .txtB. .csvC. .sas7bdatD. .dat4. 在SAS中,以下哪个选项用于指定输出数据集?A. IN=变量B. OUT=数据集C. SET=数据集D. DROP=变量5. 以下哪个SAS过程用于描述性统计分析?A. PROC GLMB. PROC TTESTC. PROC CORRD. PROC MEANS6. 在SAS中,如何创建一个新变量?A. 使用IF语句B. 使用CREATE语句C. 使用DEFINE语句D. 使用NEW语句7. SAS编程语言属于哪种类型?A. 过程式编程语言B. 面向对象编程语言C. 函数式编程语言D. 声明式编程语言8. 在SAS中,以下哪个命令用于生成报告?A. PROC REPORTB. PROC PRINTC. PROC TABULATED. PROC FREQ9. 在SAS中,以下哪个选项用于指定数据集的观察顺序?A. ORDER=数据集B. SORT=变量C. ORDERED=变量D. OBS=变量10. SAS软件主要用于哪些领域?A. 数据管理B. 数据分析C. 数据可视化D. 所有以上选项答案:1. A2. A3. C4. B5. D6. A7. A8. A9. B10. D二、简答题(每题10分,共30分)1. 简述SAS软件的主要功能。
SAS认证考试样题(50题)
SAS 中文论坛网站1.A raw data file is listed below.1---+----10---+----20---+---son Frank 01/31/89daughter June 12-25-87brother Samuel 01/17/51The following program is submitted using this file as input:data work.family;infile 'file-specification';<insert INPUT statement here >run;Which INPUT statement correctly reads the values for the variable Birthdate as SAS date values?a. i nput relation $ first_name $ birthdate date9.;b.i nput relation $ first_name $ birthdate mmddyy8.; c.i nput relation $ first_name $ birthdate : date9.; d.i nput relation $ first_name $ birthdate : mmddyy8.; Correct answer: dAn informat is used to translate the calendar date to a SAS date value. The date values are in the form of two-digit values for month-day-year, so the MMDDYY8. informat must be used. When using an informat with list input, the colon-format modifier is required to correctly associate the informat with the variable name.You can learn about•informats in Reading Date and Time Values • the colon-format modifier in Reading Free-Format Data .2.A raw data file is listed below.1---+----10---+----20---+---Jose,47,210Sue,,108The following SAS program is submitted using the raw data file above as input: data employeestats;<insert INFILE statement here>input name $ age weight;run;The following output is desired:name age weight Jose 47 210 Sue . 108Which of the following INFILE statements completes the program and accesses the data correctly?a. infile 'file-specification ' pad;b. infile 'file-specification ' dsd;SAS 中文论坛网站c. infile 'file-specification ' dlm=',';d. infile 'file-specification ' missover;Correct answer: bThe PAD option specifies that SAS pad variable length records with blanks. TheMISSOVER option prevents SAS from reading past the end of the line when reading free formatted data. The DLM= option specifies the comma as the delimiter; however,consecutive delimiters are treated as one by default. The DSD option correctly reads the data with commas as delimiters and two consecutive commas indicating a missing value like those in this raw data file.You can learn about• the PAD option in Reading Raw Data in Fixed Fields•the MISSOVER option in Creating Multiple Observations from a SingleRecord• the DLM= option and the DSD option in Reading Free-Format Data . 3.The following program is submitted:data numrecords;infile cards dlm=',';input agent1 $ agent2 $ agent3 $;cards;jones,,brownjones,spencer,brown;run;What is the value for the variable named Agent2 in the second observation?a.brown b.spencer c.' ' (missing character value) d. There is no value because only one observation is created.Correct answer: dThe CARDS statement enables you to read instream data. Any number of consecutive commas are considered to be a single delimiter as a result of the DLM= option, and the length of each variable defaults to 8 bytes. Therefore, the values jones , brownjon , and spencer are assigned to Agent1, Agent2, and Agent3, respectively, for the firstobservation. The rest of the data on the record is not read by the INPUT statement and is not output to the data set.You can learn about•the CARDS statement in Creating SAS Data Sets from Raw Data • the default length of variables in Reading Free-Format Data .4.A raw data file is listed below.1---+----10---+----20---+----30---+----40---+----50TWOSTORY 1040 2 1SANDERS ROAD $55,850CONDO 2150 4 2.5JEANS AVENUE $127,150The following program is submitted using this file as input:data work.houses;infile 'file-specification';<insert INPUT statement here>run;Which one of the following INPUT statements reads the raw data file correctly?a.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street 16.@40 price dollar8;b.input @1 style $8+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16@40 price dollar8.;c.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3.street $16.@40 price dollar8.;d.input @1 style $8.+1 sqfeet 4.+1 bedrooms 1.@20 baths 3street 16.@40 price dollar8.;Correct answer: cFormatted input requires periods as part of the informat name. The period is missing from the variables Style and Street in Answer b, the variable Baths in Answer d, and the variable Price in Answer a (which is also missing a dollar sign to read the variable Street as a character value).You can learn about formatted input and informats in Reading Raw Data in Fixed Fields.5. The following SAS program is submitted at the start of a new SAS session:libname sasdata 'SAS-data-library';data sasdata.sales;set sasdata.salesdata;profit=expenses-revenues;run;SAS中文论坛网站SAS 中文论坛网站proc print data=sales;run;The SAS data set Sasdata.Salesdata has ten observations. Which one of the following explains why a report fails to generate?a. The DATA step fails execution.b. The SAS data set Sales does not exist.c. The SAS data set Sales has no observations.d. The PRINT procedure contains a syntax error.Correct answer: bThe DATA step creates a permanent SAS data set, Sasdata.Salesdata . The PRINTprocedure is printing a temporary SAS data set, Sales , that is stored in the Work library. At the beginning of the SAS session, Work.Sales does not exist.You can learn about•creating permanent data sets with the DATA step in Creating SAS Data Setsfrom Raw Data• temporary data sets in Basic Concepts . 6. Which action assigns a reference named SALES to a permanent SAS data library? a. Issuing the command:libref SALES 'SAS-data-library'b. Issuing the command:libname SALES 'SAS-data-library'c.Submitting the statement: libref SALES 'SAS-data-library';d. Submitting the statement: libname SALES 'SAS-data-library';Correct answer: dThe LIBNAME statement assigns a reference known as a libref to a permanent SAS data library. The LIBNAME command opens the LIBNAME window.You can learn about the LIBNAME statement in Referencing Files and Setting Options .7. The following SAS program is submitted:data newstaff;set staff;<insert WHERE statement here>run;Which one of the following WHERE statements completes the program and selects only observations with a Hire_date of February 23, 2000?a. where hire_date='23feb2000'd;b. where hire_date='23feb2000';c. where hire_date='02/23/2000'd;d.where hire_date='02/23/2000';Correct answer: aA SAS date constant must take the form of one- or two-digit day, three-digit month, and two- or four-digit year, enclosed in quotation marks and followed by a d('ddmmmyy<yy>'d).You can learn about SAS date constants in Creating SAS Data Sets from Raw Data. 8. Which one of the following SAS date formats displays the SAS date value for January 16, 2002 in the form of 16/01/2002?a. DATE10.b. DDMMYY10.c. WEEKDATE10.d. DDMMYYYY10.Correct answer: bThe requested output is in day-month-year order and is 10 bytes long, so DDMMYY10. is the correct format. Although WEEKDATE10. is a valid SAS format, it does not display the SAS date value as shown in the question above. DDMMYYYY10. is not a valid SAS date format, and the DATE w. format cannot accept a length of 10.You can learn about•the DDMMYY10. format in Creating List Reports•the WEEKDATE10. format in Reading Date and Time Values.9. Which one of the following displays the contents of an external file from within a SAS session?a. the LIST procedureb.the PRINT procedurec.the FSLIST procedured.the VIEWTABLE windowCorrect answer: cThe PRINT procedure and VIEWTABLE window display the values in SAS data sets. The FSLIST procedure displays the values in external files. There is no LIST procedure in SAS.You can learn about•the PRINT procedure in Creating List ReportsSAS中文论坛网站SAS 中文论坛网站• the VIEWTABLE window in Referencing Files and Setting Options .10. The SAS data set Sashelp.Prdsale contains the variables Region and Salary with 4 observations per Region . Sashelp.Prdsale is sorted primarily by Region and within Region by Salary in descending order.The following program is submitted:data one;set sashelp.prdsale;retain temp;by region descending salary;if first.region thendo;temp=salary;output;end;if last.region thendo;range=salary-temp;output;end;run;For each region, what is the number of observation(s) written to the output data set? a. 0b. 1c. 2d. 4Correct answer: cThe expression first.region is true once for each region group. The expression last.region is true once for each region group. Therefore, each OUTPUT statement executes once for a total of 2 observations in the output data set.You can learn about the FIRST.variable expression and the OUTPUT statement in Reading SAS Data Sets .11. The following SAS program is submitted:proc contents data=sasuser.houses;run;The exhibit below contains partial output produced by the CONTENTS procedure. Data Set NameSASUSER.HOUSES Observations 15 Member TypeDATA Variables 6 EngineV9 Indexes 0 CreatedTuesday, April 22, 2003 03:09:25 PMObservation Length 56 Last ModifiedTuesday, April 22, 2003 03:09:25 PMDeleted Observations0 Protection CompressedNOData Set Type Sorted NOLabel Residential housingfor saleData Representation WINDOWS_32Encoding wlatin1 Western(Windows)Which of the following describes the Sasuser.Houses data set?a.The data set is sorted but not indexed.b.The data set is both sorted and indexed.c.The data set is not sorted but is indexed.d.The data set is neither sorted nor indexed.Correct answer: dThe exhibit above shows partial output from the CONTENTS procedure, In the top right-hand column of the output, you see that Indexes has a value of 0, which indicates that no indexes exist for this data set. Also, Sorted has a value of NO, which indicates that the data is not sorted.You can learn about the CONTENTS procedure in Referencing Files and Setting Options.12.The following SAS program is submitted:proc sort data=work.test;by fname descending salary;run;Which one of the following represents how the observations are sorted?a. The data set Work.Test is stored in ascending order by both Fname and Salary values.b. The data set Work.Test is stored in descending order by both Fname and Salary values.c. The data set Work.Test is stored in descending order by Fname and ascending order by Salary values.d. The data set Work.Test is stored in ascending order by Fname and in descending order by Salary values.Correct answer: dThe DESCENDING keyword is placed before the variable name it modifies in the BY statement, so the correct description is in descending order by Salary value within ascending Fname values.You can learn about the SORT procedure and the DESCENDING keyword in Creating List Reports.13.The following SAS program is submitted:data names;SAS中文论坛网站title='EDU';if title='EDU' thenDivision='Education';else if title='HR' thenDivision='Human Resources';else Division='Unknown';run;Which one of the following represents the value of the variable Division in the output data set?catiocationc.Human Red.Human ResourcesCorrect answer: bThe length of the variable Division is set to 9 when the DATA step compiles. Since the value of the variable Title is EDU, the first IF condition is true; therefore, the value of the variable Division is Education.You can learn about•the length of a variable in Understanding DATA Step Processing•IF-THEN statements in Creating and Managing Variables.14.Which one of the following SAS programs creates a variable named City with a value of Chicago?a.data work.airports;AirportCode='ord';if AirportCode='ORD' City='Chicago';run;b.data work.airports;AirportCode='ORD';if AirportCode='ORD' City='Chicago';run;c.data work.airports;AirportCode='ORD';if AirportCode='ORD' then City='Chicago';run;d.data work.airports;AirportCode='ORD';if AirportCode='ORD';then City='Chicago';run;Correct answer: cThe correct syntax for an IF-THEN statement is: IF expression THEN statement;In this example, the variable City is assigned a value of Chicago only if the expression AirportCode='ORD' is true.SAS中文论坛网站SAS 中文论坛网站You can learn about IF-THEN statements in Creating and Managing Variables .15.The following SAS program is submitted:data work.building;code='DAL523';code='SANFRAN604';code='HOUS731';length code $ 20;run;Which one of the following is the length of the code variable?a. 6b. 7c. 10d. 20Correct answer: aThe DATA step first goes through a compilation phase, then an execution phase. The length of a variable is set during the compilation phase and is based on the first time the variable is encountered. In this case, the variable code is set to the length of the text string DAL523 which is 6 characters long. The next assignment statements are ignored during compilation. The LENGTH statement is also ignored since the length has already been established, but a note will be written to the log.You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• the LENGTH statement in Creating and Managing Variables .16. Which of the following statements creates a numeric variable named IDnumber with a value of 4198?a. IDnumber=4198;b. IDnumber='4198';c. length IDnumber=8;d. length IDnumber $ 8;Correct answer: aThe first reference to the SAS variable in the DATA step sets the name, type, and length of the variable in the program data vector (PDV) and in the output SAS data set. The assignment statement IDnumber=4198; is the first reference and creates a numeric variable named IDnumber with a default storage length of 8 bytes.You can learn about• creating variables in the DATA step in Understanding DATA Step ProcessingSAS 中文论坛网站• numeric variables in Basic Concepts .17. The following program is submitted:data fltaten;input jobcode $ salary name $;cards;FLAT1 70000 BobFLAT2 60000 JoeFLAT3 30000 Ann;run;data desc;set fltaten;if salary>60000 then description='Over 60';else description='Under 60';run;What is value of the variable named description when the value for salary is 30000? a.Under 6 b.Under 60 c.Over 60 d. ' ' (missing character value)Correct answer: aThe variable description is being created by the IF-THEN/ELSE statement during compilation. The first occurrence of the variable description is on the IF statement, and since it is assigned the value Over 60, the length of the variable is 7. Therefore, for the salary value of 30000, description has the value of Under 6 (the 0 is truncated.) You can learn about•the compilation phase of the DATA step in Understanding DATA StepProcessing• IF-THEN/ELSE statements in Creating and Managing Variables .18. A raw data file is listed below.1---+----10---+----20---+---10232015The following program is submitted:data all_sales;infile 'file-specification';input receipts;<insert statement(s) here>run;SAS 中文论坛网站Which statement(s) complete(s) the program and produce(s) a running total of the Receipts variable?a. total+receipts;b.total 0; sum total;c. total=total+receipts;d. total=sum(total,receipts);Correct answer: aThe SUM function and the assignment statement do not retain values across iterations of the DATA step. The sum statement total+receipts; initializes total to 0, ignores missing values of receipt , retains the value of total from one iteration to the next, and adds the value of receipts to total .You can learn about the sum statement in Creating and Managing Variables .19.A raw data file is listed below.1---+----10---+----20---+---1901 21905 11910 61925 11941 1The following SAS program is submitted and references the raw data file above: data money;infile 'file-specification';input year quantity;total=total+quantity;run;What is the value of total when the data step finishes executing?a.0 b.1 c.11 d. . (missing numeric value)Correct answer: dThe variable Total is assigned a missing value during the compilation phase of the DATA step. When the first record is read in, SAS processes: total=.+2; which results in a missing value. Therefore the variable Total remains missing for all observations. You can learn about• the compilation phase of the DATA step in Understanding DATA StepProcessingSAS 中文论坛网站• using missing values with arithmetic operators in Creating SAS Data Sets fromRaw Data .20.The following program is submitted:data test;average=mean(6,4,.,2);run;What is the value of average ?a.0 b.3 c.4 d. . (missing numeric value)Correct answer: cThe MEAN function adds all of the non-missing values and divides by the number of non-missing values. In this case, 6 + 4 + 2 divided by 3 is 4.You can learn about the MEAN function in Transforming Data with SAS Functions .21.The following SAS program is submitted:data work.AreaCodes;Phonenumber=3125551212;Code='('!!substr(Phonenumber,1,3)!!')';run;Which one of the following is the value of the variable Code in the output data set? a. ( 3)b. (312)c. 3d. 312Correct answer: aAn automatic data conversion is performed whenever a numeric variable is used where SAS expects a character value. The numeric variable is written with the BEST12. format and the resulting character value is right-aligned when the conversion occurs. In this example, the value of Phonenumber is converted to character and right-aligned before the SUBSTR function is performed. Since there are only 10 digits in the value ofPhonenumber , the right-aligned value begins with two blanks. Therefore the SUBSTR function picks up two blanks and a 3, and uses the BEST12. format to assign that value to Code . Then, the parentheses are concatenated before and after the two blanks and a 3. You can learn about automatic data conversion and the SUBSTR function inTransforming Data with SAS Functions .22.The following SAS program is submitted:data work.inventory;products=7;SAS 中文论坛网站do until (products gt 6);products+1;end;run;Which one of the following is the value of the variable products in the output data set? a. 5b. 6c. 7d. 8Correct answer: dA DO UNTIL loop always executes at least once because the condition is not evaluated until the bottom of the loop. In the SAS program above, the value of Products isincremented from 7 to 8 on the first iteration of the DO UNTIL loop, before the condition is checked. Therefore the value of Products is 8.You can learn about DO UNTIL loops in Generating Data with DO Loops .23.The following program is submitted:data work.test;set work.staff (keep=salary1 salary2 salary3);<insert ARRAY statement here>run;Which ARRAY statement completes the program and creates new variables?a. array salary{3};b. array new_salary{3};c. array salary{3} salary1-salary3;d. array new_salary{3} salary1-salary3;Correct answer: bAlthough each of the ARRAY statements listed above is a valid statement, only AnswerB creates new variables named new_salary1, new_salary2 and new_salary3. AnswerC and AnswerD both create an array that groups the existing data set variables salary1, salary2, and salary3. Since the array in Answer A is named salary , it also uses the existing data set variables.You can learn about creating new variables in an ARRAY statement in Processing Variables with Arrays .24.Which of the following permanently associates a format with a variable?a. the FORMAT procedureb. a FORMAT statement in a DATA stepc. an INPUT function with format modifiersd. an INPUT statement with formatted style inputCorrect answer: bSAS 中文论坛网站To permanently associate a format with a variable, you use the FORMAT statement in a DATA step. You can use the FORMAT procedure to create a user-defined format. You use the INPUT function to convert character data values to numeric values with an informat. You use the INPUT statement to read data into a data set with an informat. You can learn about•permanently assigning a format to a variable in Creating and Managing Variables •the FORMAT statement in Creating List Reports •the FORMAT procedure in Creating and Applying User-Defined Formats •the INPUT function in Transforming Data with SAS Functions • the INPUT statement in Reading Raw Data in Fixed Fields .25.The following report is generated:Styleof homesn A skingPriceCONDO 4 $99,313RANCH 4 $68,575SPLIT3 $77,983 TWOSTORY4 $83,825Which of the following steps created the report?a. proc freq data=sasuser.houses;tables style price /nocum;format price dollar10.;label style="Style of homes"price="Asking price";run;b.proc print data=sasuser.houses; class style;var price;table style,n price*mean*f=dollar10.;label style="Style of homes"price="Asking price";run;c.proc means data=sasuser.houses n mean; class style;var price;format price dollar10.;label style="Style of homes"price="Asking price";run;d.proc report data=sasuser.houses nowd headline; column style n price;define style / group "Style of homes";define price / mean format=dollar8."Asking price";run;Correct answer: dThe FREQ procedure cannot create the average asking price. The CLASS statement and the VAR statement are not valid for use with the PRINT procedure. The MEANS procedure output would have both the N statistic and the N Obs statistic since a CLASS statement is used. The REPORT procedure produced the report.You can learn about•the FREQ procedure in Producing Descriptive Statistics•the PRINT procedure in Creating List Reports•the MEANS procedure in Producing Descriptive Statistics•the REPORT procedure in Creating Enhanced List and Summary Reports. 26.A SAS report currently flows over two pages because it is too long to fit within the specified display dimension. Which one of the following actions would change the display dimension so that the report fits on one page?a.Increase the value of the LINENO option.b.Decrease the value of the PAGENO option.c.Decrease the value of the LINESIZE option.d.Increase the value of the PAGESIZE option.Correct answer: dThe PAGESIZE= SAS system option controls the number of lines that compose a page of SAS procedure output. By increasing the number of lines available per page, the report might fit on one page.You can learn about the PAGESIZE= option in Referencing Files and Setting Options.27.Which one of the following SAS REPORT procedure options controls how column headings are displayed over multiple lines?a. SPACE=b. SPLIT=c. LABEL=d. BREAK=Correct answer: bThe SPLIT= option specifies how to split column headings. The SPACE=, LABEL= and BREAK= options are not valid options in PROC REPORT.You can learn about the SPLIT= option for the REPORT procedure in Creating Enhanced List and Summary Reports.SAS中文论坛网站28.The following SAS program is submitted:ods html file='newfile.html';proc print data=sasuser.houses;run;proc means data=sasuser.houses;run;proc freq data=sasuser.shoes;run;ods html close;proc print data=sasuser.shoes;run;How many HTML files are created?a. 1b. 2c. 3d. 4Correct answer: aBy default, one HTML file is created for each FILE= option or BODY= option in the ODS HTML statement. The ODS HTML CLOSE statement closes the open HTML file and ends the output capture. The Newfile.html file contains the output from the PRINT, MEANS, and FREQ procedures.You can learn about the ODS HTML statement in Producing HTML Output.29.A frequency report of the variable Jobcode in the Work.Actors data set is listed below.Jobcode Frequency Percent CumulativeFrequency CumulativePercentActor I233.33233.33Actor II233.33466.67Actor III233.336100.00Frequency Missing = 1The following SAS program is submitted:data work.joblevels;set work.actors;if jobcode in ('Actor I', 'Actor II') thenjoblevel='Beginner';if jobcode='Actor III' thenjoblevel='Advanced';else joblevel='Unknown';run;Which of the following represents the possible values for the variable joblevel in the Work.Joblevels data set?a.Advanced and Unknown onlySAS中文论坛网站SAS 中文论坛网站b. Beginner and Advanced onlyc. Beginner , Advanced , and Unknownd. ' ' (missing character value)Correct answer: aThe DATA step will continue to process those observations that satisfy the condition in the first IF statement Although Joblevel might be set to Beginner for one or more observations, the condition on the second IF statement will evaluate as false, and the ELSE statement will execute and overwrite the value of Joblevel as Unknown . You can learn about•the IF statement in Creating SAS Data Sets from Raw Data • the ELSE statement in Creating and Managing Variables .30.The descriptor and data portions of the Work.Salaries data set are shown below. Variable Type Len Posname Char 8 0salary Char 8 16status Char 8 8name status salary Liz S 15,600 Herman S 26,700 Marty S 35,000The following SAS program is submitted:proc print data=work.salaries;where salary<20000;run;What is displayed in the SAS log after the program is executed?a. A NOTE indicating that 1 observation is read.b. A NOTE indicating that 0 observations were read.c. A WARNING indicating that character values have been converted to numeric values.d. An ERROR indicating that the WHERE clause operator requires compatible variables. Correct answer: dSalary is defined as a character variable. Therefore, the value in the WHERE statement must be the character value 20,000 enclosed in quotation marks.You can learn about the WHERE statement in Creating List Reports .31.Which of the following statements is true when SAS encounters a syntax error in a DATA step?SAS 中文论坛网站a. The SAS log contains an explanation of the error.b. The DATA step continues to execute and the resulting data set is complete.c. The DATA step stops executing at the point of the error and the resulting data set contains observations up to that point.d. A note appears in the SAS log indicating that the incorrect statement was saved to a SAS data set for further examination.Correct answer: aSAS scans the DATA step for syntax errors during the compilation phase. If there are syntax errors, those errors get written to the log. Most syntax errors prevent further processing of the DATA step.You can learn about how SAS handles syntax errors in the DATA step in Understanding DATA Step Processing .32.Which TITLE statement would display JANE'S DOG as the text of the title?a. title "JANE"S DOG";b. title 'JANE"S DOG';c. title "JANE'S DOG";d. title 'JANE' ' 'S DOG';Correct answer: cThe title in a TITLE statement must be enclosed in a pair of matched quotation marks. Unbalanced quotation marks can cause problems for SAS. To hide an unmatched single quotation mark, surround the title text with matched double quotation marks.You can learn about•the TITLE statement in Creating List Reports • unbalanced quotation marks in Editing and Debugging SAS Programs .33.The following SAS program is submitted:data test;input animal1 $ animal2 $mlgrams1 mlgrams2;cards;hummingbird ostrich 54000.39 90800000.87;run;Which one of the following represents the values of each variable in the output data set?a. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000b. animal1 animal2 mlgrams1 mlgrams2 hummingb ostrich 54000.39 90800000.87c. animal1 animal2 mlgrams1 mlgrams2 hummingbird ostrich 54000.39 90800000d. animal1 animal2 mlgrams1 mlgrams2。
全等三角形综合练习题含答案
全等三角形的判定(SSS)1、如图1,AB=AD,CB=CD,∠B=30°,∠BAD=46°,则∠ACD的度数是( )°°°°2、如图2,线段AD与BC交于点O,且AC=BD,AD=BC,•则下面的结论中不正确的是( )A.△ABC≌△BADB.∠CAB=∠DBA =OC D.∠C=∠D3、在△ABC和△A1B1C1中,已知AB=A1B1,BC=B1C1,则补充条件____________,可得到△ABC≌△A1B1C1.4、如图3,AB=CD,BF=DE,E、F是AC上两点,且AE=CF.欲证∠B=∠D,可先运用等式的性质证明AF=________,再用“SSS”证明______≌_______得到结论.5、如图,AB=AC,BD=CD,求证:∠1=∠2.6、如图,已知AB=CD,AC=BD,求证:∠A=∠D.7、如图,AC与BD交于点O,AD=CB,E、F是BD上两点,且AE=CF,DE=BF.请推导下列结论:⑴∠D=∠B;⑵AE∥CF.8、已知如图,A、E、F、C四点共线,BF=DE,AB=CD.⑴请你添加一个条件,使△DEC≌△BFA;⑵在⑴的基础上,求证:DE∥BF.全等三角形的判定方法SAS专题练习1.如图,AB=AC,AD=AE,欲证△ABD≌△ACE,可补充条件( )A.∠1=∠2B.∠B=∠CC.∠D=∠ED.∠BAE=∠CAD2.能判定△ABC≌△A′B′C′的条件是()A.AB=A′B′,AC=A′C′,∠C=∠C′B. AB=A′B′,∠A=∠A′,BC=B′C′C. AC=A′C′,∠A=∠A′,BC=B′CD. AC=A′C′,∠C=∠C′,BC=B′C3.如图,AB与CD交于点O,OA=OC,OD=OB,∠AOD= ,根据_________可得到△AOD≌△COB,从而可以得到AD=_________.4.如图,已知BD=CD,要根据“SAS”判定△ABD≌△ACD,则还需添加的条件是。
sas 综合习题
SAS综合练习题1. 今有某种型号的电池3批,他们分别是A,B,C,三个工厂所生产的,为评比其质量,各随机抽取5支电池为其样品,经实验的其寿命(小时)如下:A B C40 42 26 28 39 5048 45 34 32 40 5038 30 43试在显著性水平0.05下检验电池的平均寿命有无显著的差异,若差异是显著的,试求均值差是显著的,试求均值差ua-ub,ua-uc,及ub-uc的置信水平为95%的置信区间。
解:输入:data L1;Do type=1to3;Do rep=1to5;input x@@;output;end;end;cards;40 42 48 45 38 26 28 34 32 30 39 50 40 50 43Proc anova;class type;model x=type;run;输出:The SAS System 19:13 Sunday, April 18, 2011 1The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 2 615.6000000 307.8000000 17.07 0.0003Error 12 216.4000000 18.0333333Corrected Total 14 832.0000000R-Square Coeff Var Root MSE x Mean0.739904 10.88863 4.246567 39.00000Source DF Anova SS Mean Square F Value Pr > Ftype 2 615.6000000 307.8000000 17.07 0.0003 答:因为0.0003<0.05,所以拒绝假设A B C 组之间有显著性差异2,为了寻找飞机控制板上仪器表的最佳布置位置,试验了三个方案,观察员在紧急情况的反应时间(以1/10秒计),随机地选择28名领航员,得到他们对于试求u1-u2,u1-u3,u2-u3置信水平为0.95的置信区间输入:DATA L2;DO A=1TO3;INPUT N;DO J=1TO N;INPUT X@@;OUTPUT;END;END;CARDS;814 13 9 15 11 13 14 111210 12 7 11 8 12 9 10 13 9 10 9811 5 9 10 6 8 8 7;PROC GLM;CLASS A;MODEL X=A;RUN;输出:The SAS System 19:13 Sunday, April 18, 2011 3The GLM ProcedureDependent Variable: XSum ofSource DF Squares Mean Square F Value Pr > FModel 2 81.4285714 40.7142857 11.31 0.0003 Error 25 90.0000000 3.6000000Corrected Total 27 171.4285714The SAS System 19:53 Monday, April 19, 2010 2The GLM ProcedureDependent Variable: XSum ofSource DF Squares Mean Square F Value Pr > FModel 2 81.4285714 40.7142857 11.31 0.0003 Error 25 90.0000000 3.6000000Corrected Total 27 171.4285714R-Square Coeff Var Root MSE X Mean0.475000 18.70643 1.897367 10.14286Source DF Type I SS Mean Square F Value Pr > FA 2 81.42857143 40.71428571 11.31 0.0003Source DF Type III SS Mean Square F Value Pr > FA 2 81.42857143 40.71428571 11.31 0.0003分析:方差分析得F=11.31.P=0.0003,按 =0.05的水准下,各个方案的反应时间有显著差异。
SAS认证220道_练习题及详细答案
SAS Certificate Base Practice Questions and Detailed Answers Chapter 1: Basic ConceptsChapter 2: Referencing Files and Setting OptionsChapter 3: Editing and Debugging SAS ProgramsChapter 4: Creating List ReportsChapter 5: Creating SAS Data Sets from Raw DataChapter 6: Understanding DATA Step ProcessingChapter 7: Creating and Applying User-Defined FormatsChapter 8: Creating Enhanced List and Summary ReportsChapter 9: Producing Descriptive StatisticsChapter 10: Producing HTML OutputChapter 11: Creating and Managing VariablesChapter 12: Reading SAS Data SetsChapter 13: Combining SAS Data SetsChapter 14: Transforming Data with SAS FunctionsChapter 15: Generating Data with DO LoopsChapter 16: Processing Variables with ArraysChapter 17: Reading Raw Data in Fixed FieldsChapter 18: Reading Free-Format DataChapter 19: Reading Date and Time ValuesChapter 20: Creating a Single Observation from Multiple RecordsChapter 21: Creating Multiple Observations from a Single RecordChapter 22: Reading Hierarchical FilesChapter 1: Basic Concepts Answer Key1.How many observations and variables does the data set below contain?a. 3 observations, 4 variablesb. 3 observations, 3 variablesc. 4 observations, 3 variablesd.can't tell because some values are missingCorrect answer:cRows in the data set are called observations, and columns are called variables. Missing values don't affect the structure of the data set.2.How many program steps are executed when the program below is processed?data user.tables;infile jobs;input date name $ job $;run;proc sort data=user.tables;by name;run;proc print data=user.tables;run;a.threeb.fourc.fived.sixCorrect answer:aWhen it encounters a DATA, PROC, or RUN statement, SAS stops reading statements andexecutes the previous step in the program. The program above contains one DATA step and two PROC steps, for a total of three program steps.3.What type of variable is the variable AcctNum in the data set below?a.numericb.characterc.can be either character or numericd.can't tell from the data shownCorrect answer:bIt must be a character variable, because the values contain letters and underscores, which are not valid characters for numeric values.4.What type of variable is the variable Wear in the data set below?a.numericb.characterc.can be either character or numericd.can't tell from the data shownCorrect answer:aIt must be a numeric variable, because the missing value is indicated by a period rather than by a blank.5.Which of the following variable names is valid?a.4BirthDateb.$Costc._Items_d.Tax-RateCorrect answer:cVariable names follow the same rules as SAS data set names. They can be 1 to 32 characters long, must begin with a letter (A–Z, either uppercase or lowercase) or an underscore, and can continue with any combination of numbers, letters, or underscores.6.Which of the following files is a permanent SAS file?a.Sashelp.PrdSaleb.Sasuser.MySalesc.Profits.Quarter1d.all of the aboveCorrect answer:dTo store a file permanently in a SAS data library, you assign it a libref other than the default Work. For example, by assigning the libref Profits to a SAS data library, you specify that files within the library are to be stored until you delete them. Therefore, SAS files in the Sashelp and Sasuser libraries are permanent files.7.In a DATA step, how can you reference a temporary SAS data set named Forecast?a.Forecastb.Work.Forecastc.Sales.Forecast (after assigning the libref Sales)d.only a and b aboveCorrect answer:dTo reference a temporary SAS file in a DATA step or PROC step, you can specify the one-level name of the file (for example, Forecast) or the two-level name using the libref Work (for example, Work.Forecast).8.What is the default length for the numeric variable Balance?a. 5b. 6c.7d.8Correct answer:dThe numeric variable Balance has a default length of 8. Numeric values (no matter how many digits they contain) are stored in 8 bytes of storage unless you specify a different length.9.How many statements does the following SAS program contain?proc print data=new.prodsalelabel double;var state day price1 price2; where state='NC';label state='Name of State';run;a.threeb.fourc.fived.sixCorrect answer:cThe five statements are•PROC PRINT statement (two lines long)•VAR statement•WHERE statement (on the same line as the VAR statement)•LABEL statement•RUN statement (on the same line as the LABEL statement).10.What is a SAS data library?a. a collection of SAS files, such as SAS data sets and catalogsb.in some operating environments, a physical collection of SAS filesc.in some operating environments, a logically related collection of SAS filesd.all of the aboveCorrect answer:dEvery SAS file is stored in a SAS data library, which is a collection of SAS files, such as SAS data sets and catalogs. In some operating environments, a SAS data library is a physical collection of files. In others, the files are only logically related. In the Windows and UNIX environments, a SAS data library is typically a group of SAS files in the same folder or directory.Chapter 2: Referencing Files and Setting Options1.If you submit the following program, how does the output look?options pagesize=55 nonumber;proc tabulate data=clinic.admit;class actlevel;var age height weight;table actlevel,(age height weight)*mean;run;options linesize=80;proc means data=clinic.heart min max maxdec=1;var arterial heart cardiac urinary;class survive sex;run;a.The PROC MEANS output has a print line width of 80 characters, but the PROCTABULATE output has no print line width.b.The PROC TABULATE output has no page numbers, but the PROC MEANS outputhas page numbers.c.Each page of output from both PROC steps is 55 lines long and has no page numbers,and the PROC MEANS output has a print line width of 80 characters.d.The date does not appear on output from either PROC step.Correct: answer:cWhen you specify a system option, it remains in effect until you change the option or end your SAS session, so both PROC steps generate output that is printed 55 lines per page with no page numbers. If you don't specify a system option, SAS uses the default value for that system option.2.In order for the date values 05May1955 and 04Mar2046 to be read correctly, what value mustthe YEARCUTOFF= option have?a. a value between 1947 and 1954, inclusiveb.1955 or higherc.1946 or higherd.any valueCorrect answer:dAs long as you specify an informat with the correct field width for reading the entire date value, the YEARCUTOFF= option doesn't affect date values that have four-digit years.3.When you specify an engine for a library, you are always specifyinga.the file format for files that are stored in the library.b.the version of SAS that you are using.c.access to other software vendors' files.d.instructions for creating temporary SAS files.Correct answer:aA SAS engine is a set of internal instructions that SAS uses for writing to and reading from files in a SAS library. Each engine specifies the file format for files that are stored in the library, which in turn enables SAS to access files with a particular format. Some engines access SAS files, and other engines support access to other vendors' files.4.Which statement prints a summary of all the files stored in the library named Area51?a.proc contents data=area51._all_ nods;b.proc contents data=area51 _all_ nods;c.proc contents data=area51 _all_ noobs;d.proc contents data=area51 _all_.nods;Correct answer:aTo print a summary of library contents with the CONTENTS procedure, use a period to append the _ALL_ option to the libref. Adding the NODS option suppresses detailed information about the files.5.The following PROC PRINT output was created immediately after PROC TABULATEoutput. Which SAS system options were specified when the report was created?a.OBS=, DATE, and NONUMBERb.PAGENO=1, and DATEc.NUMBER and DATE onlyd.none of the aboveCorrect answer:bClearly, the DATE and PAGENO= options are specified. Because the page number on the output is 1, even though PROC TABULATE output was just produced. If you don't specify PAGENO=, all output in the Output window is numbered sequentially throughout your SAS session.6.Which of the following programs correctly references a SAS data set named SalesAnalysisthat is stored in a permanent SAS library?a.data saleslibrary.salesanalysis;set mydata.quarter1sales;if sales>100000;run;b.data mysales.totals;set sales_99.salesanalysis;if totalsales>50000;run;c.proc print data=salesanalysis.quarter1;var sales salesrep month;run;d.proc freq data=1999data.salesanalysis;tables quarter*sales; run;Correct answer:bLibrefs must be 1 to 8 characters long, must begin with a letter or underscore, and can contain only letters, numbers, or underscores. After you assign a libref, you specify it as the first element in the two-level name for a SAS file.7.Which time span is used to interpret two-digit year values if the YEARCUTOFF= option isset to 1950?a.1950-2049b.1950-2050c.1949-2050d.1950-2000Correct answer:aThe YEARCUTOFF= option specifies which 100-year span is used to interpret two-digit year values. The default value of YEARCUTOFF= is 1920. However, you can override the default and change the value of YEARCUTOFF= to the first year of another 100-year span. If you specify YEARCUTOFF=1950, then the 100-year span will be from 1950 to 2049.8.Asssuming you are using SAS code and not special SAS windows, which one of thefollowing statements is false?a.LIBNAME statements can be stored with a SAS program to reference the SAS libraryautomatically when you submit the program.b.When you delete a libref, SAS no longer has access to the files in the library.However, the contents of the library still exist on your operating system.c.Librefs can last from one SAS session to another.d.You can access files that were created with other vendors' software by submitting aLIBNAME statement.Correct answer:cThe LIBNAME statement is global, which means that librefs remain in effect until you modify them, cancel them, or end your SAS session. Therefore, the LIBNAME statement assigns the libref for the current SAS session only. You must assign a libref before accessingSAS files that are stored in a permanent SAS data library.9.What does the following statement do?libname osiris spss 'c:\myfiles\sasdata\data';a.defines a library called Spss using the OSIRIS engineb.defines a library called Osiris using the SPSS enginec.defines two libraries called Osiris and Spss using the default engined.defines the default library using the OSIRIS and SPSS enginesCorrect answer:bIn the LIBNAME statement, you specify the library name before the engine name. Both are followed by the path.10.What does the following OPTIONS statement do?options pagesize=15 nodate;a.suppresses the date and limits the page size of the logb.suppresses the date and limits the vertical page size for text outputc.suppresses the date and limits the vertical page size for text and HTML outputd.suppresses the date and limits the horizontal page size for text outputCorrect answer:bThese options affect the format of listing output only. NODATE suppresses the date and PAGESIZE= determines the number of rows to print on the page.Chapter 3: Editing and Debugging SAS Programs Answer Key1.As you write and edit SAS programs it's a good idea toa.begin DATA and PROC steps in column one.b.indent statements within a step.c.begin RUN statements in column one.d.all of the aboveCorrect answer:dAlthough you can write SAS statements in almost any format, a consistent layout enhances readability and enables you to understand the program's purpose. It's a good idea to begin DATA and PROC steps in column one, to indent statements within a step, to begin RUN statements in column one, and to include a RUN statement after every DATA step or PROC step.2.What usually happens when an error is detected?a.SAS continues processing the step.b.SAS continues to process the step, and the log displays messages about the error.c.SAS stops processing the step in which the error occurred, and the log displaysmessages about the error.d.SAS stops processing the step in which the error occurred, and the program outputdisplays messages about the error.Correct answer:cSyntax errors generally cause SAS to stop processing the step in which the error occurred. When a program that contains an error is submitted, messages regarding the problem also appear in the SAS log. When a syntax error is detected, the SAS log displays the word ERROR, identifies the possible location of the error, and gives an explanation of the error.3. A syntax error occurs whena.some data values are not appropriate for the SAS statements that are specified in aprogram.b.the form of the elements in a SAS statement is correct, but the elements are not validfor that usage.c.program statements do not conform to the rules of the SAS language.d.none of the aboveCorrect canswer:Syntax errors are common types of errors. Some SAS system options, features of the Editorwindow, and the DATA step debugger can help you identify syntax errors. Other types oferrors include data errors, semantic errors, and execution-time errors.4.How can you tell whether you have specified an invalid option in a SAS program?a. A log message indicates an error in a statement that seems to be valid.b. A log message indicates that an option is not valid or not recognized.c.The message "PROC running" or "DATA step running" appears at the top of theactive window.d.You can't tell until you view the output from the program.Correct answer:bWhen you submit a SAS statement that contains an invalid option, a log message notifies you that the option is not valid or not recognized. You should recall the program, remove or replace the invalid option, check your statement syntax as needed, and resubmit the corrected program.5.Which of the following programs contains a syntax error?Correct answer:bThe DATA step contains a misspelled keyword (dat instead of data). However, this is such a common (and easily interpretable) error that SAS produces only a warning message, not an error.6.What does the following log indicate about your program?proc print data=sasuser.cargo99var origin dest cargorev;2276ERROR 22-322: Syntax error, expecting one of the following:;, (, DATA, DOUBLE, HEADING, LABEL, N, NOOBS, OBS, ROUND, ROWS, SPLIT, STYLE,UNIFORM, WIDTH.ERROR 76-322: Syntax error, statement will be ignored.11 run;a.SAS identifies a syntax error at the position of the VAR statement.b.SAS is reading VAR as an option in the PROC PRINT statement.c.SAS has stopped processing the program because of errors.d.all of the aboveCorrect answer:dBecause there is a missing semicolon at the end of the PROC PRINT statement, SAS interprets VAR as an option in PROC PRINT and finds a syntax error at that location. SAS stops processing programs when it encounters a syntax error.Chapter 4: Creating List Reports Answer Key 1.Which PROC PRINT step below creates the following output?Correct answer:cThe DATA= option specifies the data set that you are listing, and the ID statement replaces the Obs column with the specified variable. The VAR statement specifies variables and controls the order in which they appear, and the WHERE statement selects rows based on a condition. The LABEL option in the PROC PRINT statement causes the labels that are specified in the LABEL statement to be displayed.2.Which of the following PROC PRINT steps is correct if labels are not stored with thedata set?Correct aanswer:You use the DATA= option to specify the data set to be printed. The LABEL optionspecifies that variable labels appear in output instead of variable names.3.Which of the following statements selects from a data set only those observations forwhich the value of the variable Style is RANCH, SPLIT, or TWOSTORY?Correct answer:dIn the WHERE statement, the IN operator enables you to select observations based on several values. You specify values in parentheses and separate them by spaces or commas. Character values must be enclosed in quotation marks and must be in the same case as in the data set.4.If you want to sort your data and create a temporary data set named Calc to store thesorted data, which of the following steps should you submit?Correct answer:cIn a PROC SORT step, you specify the DATA= option to specify the data set to sort. The OUT= option specifies an output data set. The required BY statement specifies the variable(s) to use in sorting the data.5.Which options are used to create the following PROC PRINT output?13:27 Monday, March 22, 1999 Patient Arterial Heart Cardiac Urinary203 88 95 66 11054 83 183 95 0664 72 111 332 12210 74 97 369 0101 80 130 291 0a.the DATE system option and the LABEL option in PROC PRINTb.the DATE and NONUMBER system options and the DOUBLE and NOOBSoptions in PROC PRINTc.the DATE and NONUMBER system options and the DOUBLE option inPROC PRINTd.the DATE and NONUMBER system options and the NOOBS option in PROCPRINTCorrect answer:bThe DATE and NONUMBER system options cause the output to appear with the date but without page numbers. In the PROC PRINT step, the DOUBLE option specifies double spacing, and the NOOBS option removes the default Obs column.6.Which of the following statements can you use in a PROC PRINT step to create thisoutput?Correct answer:dYou do not need to name the variables in a VAR statement if you specify them in the SUM statement, but you can. If you choose not to name the variables in the VAR statement as well, then the SUM statement determines the order of the variables in the output.7.What happens if you submit the following program?proc sort data=clinic.diabetes;run;proc print data=clinic.diabetes;var age height weight pulse;where sex='F';run;a.The PROC PRINT step runs successfully, printing observations in their sortedorder.b.The PROC SORT step permanently sorts the input data set.c.The PROC SORT step generates errors and stops processing, but the PROCPRINT step runs successfully, printing observations in their original (unsorted)order.d.The PROC SORT step runs successfully, but the PROC PRINT step generateserrors and stops processing.Correct answer:cThe BY statement is required in PROC SORT. Without it, the PROC SORT step fails. However, the PROC PRINT step prints the original data set as requested.8.If you submit the following program, which output does it create?proc sort data=finance.loans out=work.loans;by months amount;run;proc print data=work.loans noobs; var months;sum amount payment;where months<360;run;a.b.c.d.Correct answer:aColumn totals appear at the end of the report in the same format as the values of the variables, so b is incorrect. Work.Loans is sorted by Month and Amount, so c isincorrect. The program sums both Amount and Payment, so d is incorrect.9.Choose the statement below that selects rows which•the amount is less than or equal to $5000•the account is 101-1092 or the rate equals 0.095.Correct answer:cTo ensure that the compound expression is evaluated correctly, you can use parentheses to groupaccount='101-1092' or rate eq 0.095OBS Account Amount Rate MonthsPayment1 101-1092 $22,000 10.00%60 $467.432 101-1731 $114,0009.50% 360 $958.573 101-1289 $10,000 10.50%36 $325.024 101-3144 $3,500 10.50%12 $308.525 103-1135 $8,700 10.50%24 $403.476 103-1994 $18,500 10.00%60 $393.077 103-2335 $5,000 10.50%48 $128.028 103-3864 $87,500 9.50% 360 $735.759 103-3891 $30,000 9.75% 360 $257.75For example, from the data set above, a and b above select observations 2 and 8 (those that have a rate of 0.095); c selects no observations; and d selects observations 4 and 7 (those that have an amount less than or equal to 5000).10.What does PROC PRINT display by default?a.PROC PRINT does not create a default report; you must specify the rows andcolumns to be displayed.b.PROC PRINT displays all observations and variables in the data set. If youwant an additional column for observation numbers, you can request it.c.PROC PRINT displays columns in the following order: a column forobservation numbers, all character variables, and all numeric variables.d.PROC PRINT displays all observations and variables in the data set, a columnfor observation numbers on the far left, and variables in the order in which they occur in the data set.Correct answer:dYou can remove the column for observation numbers. You can also specify the variables you want, and you can select observations according to conditions.Chapter 5: Creating SAS Data Sets from Raw Data Answer Key1.Which SAS statement associates the fileref Crime with the raw data fileC:\States\Data\Crime?a.filename crime 'c:\states\data\crime';b.filename crime c:\states\data\crime;c.fileref crime 'c:\states\data\crime';d.filename 'c:\states\data\crime' crime; Correct aanswer:Before you can read your raw data, you must reference the raw data file by creating afileref. You assign a fileref by using a FILENAME statement in the same way thatyou assign a libref by using a LIBNAME statement.2.Filerefs remain in effect untila.you change them.b.you cancel them.c.you end your SAS session.d.all of the aboveCorrect answer:dLike LIBNAME statements, FILENAME statements are global; they remain in effect until you change them, cancel them, or end your SAS session.3.Which statement identifies the name of a raw data file to be read with the filerefProducts and specifies that the DATA step read only records 1-15?a.infile products obs 15;b.infile products obs=15;c.input products obs=15;d.input products 1-15;Correct answer:bYou use an INFILE statement to specify the raw data file to be read. You can specify a fileref or an actual filename (in quotation marks). The OBS= option in the INFILE statement enables you to process only records 1 through n.4.Which of the following programs correctly writes the observations from the data setbelow to a raw data file?Correct answer:dThe keyword _NULL_ in the DATA statement enables you to use the power of the DATA step without actually creating a SAS data set. You use the FILE and PUT statements to write out the observations from a SAS data set to a raw data file. The FILE statement specifies the raw data file and the PUT statement describes the lines towrite to the raw data file. The filename and location that are specified in the FILE statement must be enclosed in quotation marks.5.Which raw data file can be read using column input?a.b.c.d.all of the aboveCorrect answer:bColumn input is appropriate only in some situations. When you use column input, your data must be standard character or numeric values, and they must be in fixed fields. That is, values for a particular variable must be in the same location in all records.6.Which program creates the output shown below?Correct answer:aThe INPUT statement creates a variable using the name that you assign to each field. Therefore, when you write an INPUT statement, you need to specify the variable names exactly as you want them to appear in the SAS data set.7.Which statement correctly reads the fields in the following order: StockNumber,Price, Item, Finish, Style?Field Name Start Column End Column Data TypeStockNumber 1 3 characterFinish 5 9 characterStyle 11 18 characterItem 20 24 characterPrice 27 32 numericCorrec t answer:bYou can use column input to read fields in any order. You must specify the variable name to be created, identify character values with a $, and name the correct starting column and ending column for each field.8.Which statement correctly re-defines the values of the variable Income as 100percent higher?a.income=income*1.00;b.income=income+(income*2.00);c.income=income*2;d.income=*2;Correct answer:cTo re-define the values of the variable Income in an Assignment statement, you specify the variable name on the left side of the equal sign and an appropriate expression including the variable name on the right side of the equal sign.9.Which program correctly reads instream data?a.data finance.newloan;input datalines;if country='JAPAN';MonthAvg=amount/12;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;b.data finance.newloan;input Year 1-4 Country $ 6-11Vehicle $ 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;run;c.data finance.newloan;input Year 1-4 Country 6-11Vehicle 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;d.data finance.newloan;input Year 1-4 Country $ 6-11Vehicle $ 13-18 Amount 20-28;if country='JAPAN';MonthAvg=amount/12;datalines;1998 US CARS 194324.121998 US TRUCKS 142290.301998 CANADA CARS 10483.441998 CANADA TRUCKS 93543.641998 MEXICO CARS 22500.571998 MEXICO TRUCKS 10098.881998 JAPAN CARS 15066.431998 JAPAN TRUCKS 40700.34;Correct answer:dTo read instream data, you specify a DATALINES statement and data lines, followed by a null statement (single semicolon) to indicate the end of the input data. Program a contains no DATALINES statement, and the INPUT statement doesn't specify the fields to read. Program b contains no data lines, and the INPUT statement in program c doesn't specify the necessary dollar signs for the character variables Country and Vehicle.10.Which SAS statement subsets the raw data shown below so that only the observationsin which Sex (in the second field) has a value of F are processed?a.if sex=f;b.if sex=F;c.if sex='F';d. a or bCorrect answer:cTo subset data, you can use a subsetting IF statement in any DATA step to process only those observations that meet a specified condition. Because Sex is a character variable, the value F must be enclosed in quotation marks and must be in the same case as in the data set.Chapter 6: Understanding DATA Step Processing Answer Key1.Which of the following is not created during the compilation phase?。
SAS题目(含答案)
SAS题目(含答案)1、某农村地区1999 年14 岁女孩的身高资料如下。
142.3 148.8 142.7 144.4 144.7 145.1 143.3 154.2 152.3 142.7 156.6137.9 143.9 141.2 139.3 145.8 142.2 137.9 141.2 150.6 142.7 151.3142.4 141.5 141.9 147.9 125.8 139.9 148.9 154.9 145.7 140.8 139.6148.8 147.8 146.7 132.7 149.7 154.0 158.2 138.2 149.8 151.1 140.1140.5 143.4 152.9 147.5 147.7 162.6 141.6 143.6 144.0 150.6 138.9150.8 147.9 136.9 146.5 130.6 142.5 149.0 145.4 139.5 148.9 144.5141.8 148.1 145.4 134.6 130.5 145.2 146.2 146.4 142.4 137.1 141.4144.0 129.4 142.8 132.1 141.8 143.3 143.8 134.7 147.1 140.9 137.4142.5 146.6 135.5 146.8 156.3 150.0 147.3 142.9 141.4 134.7 138.5146.6 134.5 135.1 141.9 142.1 138.1 134.9 146.7 138.5 139.6 139.2148.8 150.3 140.7 143.5 140.2 143.6 138.7 138.9 143.5 139.9 134.4133.1 145.9 139.2 137.4 142.3 160.9 137.7 142.9 126.8问题:(1)计算均数、中位数;计算均数的95%可信区间;(2)计算四分位间距、标准差、变异系数;计算标准误;\(3)请进行正态性检验;(4)观察频数分布情况(直方图);答:data a;input height@@;cards;142.3 148.8 142.7 144.4 144.7 145.1 143.3 154.2 152.3 142.7 156.6137.9 143.9 141.2 139.3 145.8 142.2 137.9 141.2 150.6 142.7 151.3142.4 141.5 141.9 147.9 125.8 139.9 148.9 154.9 145.7 140.8 139.6148.8 147.8 146.7 132.7 149.7 154.0 158.2 138.2 149.8 151.1 140.1140.5 143.4 152.9 147.5 147.7 162.6 141.6 143.6 144.0 150.6 138.9150.8 147.9 136.9 146.5 130.6 142.5 149.0 145.4 139.5 148.9 144.5141.8 148.1 145.4 134.6 130.5 145.2 146.2 146.4 142.4 137.1 141.4144.0 129.4 142.8 132.1 141.8 143.3 143.8 134.7 147.1 140.9 137.4142.5 146.6 135.5 146.8 156.3 150.0 147.3 142.9 141.4 134.7 138.5146.6 134.5 135.1 141.9 142.1 138.1 134.9 146.7 138.5 139.6 139.2148.8 150.3 140.7 143.5 140.2 143.6 138.7 138.9 143.5 139.9 134.4133.1 145.9 139.2 137.4 142.3 160.9 137.7 142.9 126.8;run;proc means mean median CLM qrange std cv stderr;var height;run;proc univariate normal;histogram height;(要先写univariate,再写histogram) var height;run;2.已知正常人某蛋白平均值为300。
sas期末试题及答案解析
sas期末试题及答案解析一、选择题1. 下列哪个选项是正确的?a) SAS是一种统计分析软件b) SAS是一种操作系统c) SAS是一种数据库管理系统d) SAS是一种编程语言答案:a) SAS是一种统计分析软件解析:SAS(Statistical Analysis System,统计分析系统)是一套用于数据管理、报表制作、统计分析、数据挖掘等功能的软件系统。
它由美国SAS公司开发,广泛应用于各个领域的数据处理和决策支持。
2. SAS的基本语法是什么?a) Javab) C++c) Pythond) SAS答案:d) SAS解析:SAS软件具有自己的编程语言,即SAS语言。
它是一种类似于SQL的专用于数据处理和分析的语言,具有丰富的数据操作和统计分析函数。
3. 在SAS中,用于读取外部数据文件的语句是什么?a) INPUTb) OUTPUTc) EXPORTd) IMPORT答案:d) IMPORT解析:在SAS中,使用IMPORT语句可以将外部数据文件导入到SAS数据集中,方便后续的数据处理和分析。
4. 下列哪个函数可以用于计算某一列数据的平均值?a) SUMb) COUNTc) MINd) MEAN答案:d) MEAN解析:MEAN函数可以用于计算某一列数据的平均值,它是统计分析中常用的函数之一。
二、填空题1. SAS中用于创建新变量的语句是_______。
答案:DATA解析:在SAS中,使用DATA语句可以创建一个新的数据集,并进行后续的数据处理和分析。
2. SAS中用于选择某些特定观测值的语句是________。
答案:WHERE解析:WHERE语句可以用于筛选出符合特定条件的观测值,方便进行针对性的分析和处理。
三、问答题1. 请简要介绍一下SAS的应用领域。
答:SAS的应用领域非常广泛,包括但不限于以下几个方面:1) 统计分析:SAS是一套强大的统计分析软件,可以对大量的数据进行统计描述、推断分析、回归分析、时间序列分析等,为用户提供科学而有效的分析结果。
sas练习题
SAS练习题一、基础操作类1. 如何在SAS中创建一个数据集?2. 请写出SAS中读取外部数据文件的语句。
3. 如何在SAS中查看数据集的结构?4. 如何在SAS中对数据集进行排序?5. 请写出SAS中合并两个数据集的语句。
6. 如何在SAS中删除一个数据集?7. 请简述SAS中变量的命名规则。
8. 如何在SAS中修改数据集的属性?9. 请写出SAS中创建临时数据集和永久数据集的语句。
10. 如何在SAS中导入和导出Excel文件?二、数据处理类1. 如何在SAS中对缺失值进行处理?2. 请写出SAS中计算变量总和、平均数、最大值和最小值的语句。
3. 如何在SAS中进行条件筛选?4. 请简述SAS中日期和时间的处理方法。
5. 如何在SAS中实现数据的分组汇总?6. 请写出SAS中创建新变量的语句。
7. 如何在SAS中进行数据类型转换?8. 请写出SAS中替换变量值的语句。
9. 如何在SAS中实现数据的横向连接和纵向连接?10. 请简述SAS中数组的使用方法。
三、统计分析类1. 如何在SAS中进行单因素方差分析?2. 请写出SAS中进行t检验的语句。
3. 如何在SAS中计算相关系数?4. 请简述SAS中回归分析的基本步骤。
5. 如何在SAS中进行主成分分析?6. 请写出SAS中进行聚类分析的语句。
7. 如何在SAS中实现时间序列分析?8. 请简述SAS中生存分析的基本概念。
9. 如何在SAS中进行非参数检验?10. 请简述SAS中多重响应分析的方法。
四、图形绘制类1. 如何在SAS中绘制直方图?2. 请写出SAS中绘制散点图的语句。
3. 如何在SAS中绘制饼图?4. 请简述SAS中绘制箱线图的方法。
5. 如何在SAS中绘制条形图?6. 请写出SAS中绘制折线图的语句。
7. 如何在SAS中设置图表的颜色和样式?8. 请简述SAS中绘制雷达图的方法。
9. 如何在SAS中实现图表的交互功能?10. 请简述SAS中图表导出的方法。
sas练习题
sas练习题由于我无法确定题目“sas练习题”的具体要求和格式,因此我将按照一般文章的格式和流程,为你提供一篇关于SAS练习题的文章。
文章内容涉及SAS的基本介绍、应用领域、练习题示例等。
文章正文如下:SAS练习题引言:在当今信息时代,大数据的崛起使得数据管理和分析变得愈发重要。
统计分析技术成为了处理和理解这些数据的关键。
SAS(Statistical Analysis System)作为一种功能强大的统计软件,被广泛应用于各个领域。
为了帮助读者更好地掌握SAS,下面将通过一些练习题来加深对这一工具的理解和应用。
SAS练习题示例:1. 问题描述:某公司的销售数据存储在一个包含了销售额、产品类型、销售日期等信息的数据集中。
请使用SAS提取某一指定时间段内销售额超过10000的产品。
解决方案:利用SAS的数据处理功能,我们可以按照以下步骤解决该问题。
第一步:导入数据集。
```sasdata sales;/* 数据导入代码 */run;```第二步:筛选指定时间段内的数据。
```sasdata selected_sales;set sales;where sales_date between '2022-01-01'd and '2022-12-31'd andsales_amount > 10000;run;```2. 问题描述:某医院的病人数据存储在一个包含了病人姓名、年龄、性别、住院日期等信息的数据集中。
请使用SAS计算该医院病人的平均年龄和男女病人的人数。
解决方案:利用SAS的统计分析功能,我们可以按照以下步骤解决该问题。
第一步:导入数据集。
```sasdata patients;/* 数据导入代码 */run;```第二步:计算平均年龄。
```sasproc means data=patients mean;var age;run;```第三步:计算男女病人人数。
sas习题及答案
sas习题及答案【篇一:sas综合题1-15】txt>1. 创建一包含10000个变量(x1-x10000),100个观测值的sas数据集。
分别用data步,data步数组语句和iml过程实现。
data步:data p1(drop=i); retain x1-x10000 0; do i=1 to 100; output; end; run;data步数组:data p1(drop=i); array x x1-x10000; do i=1 to 100;do over x; x=ranuni(0); end; output;end;run;宏:%macro names(name,number,obs); data a;%do i=1 %to obs; %do n=1 %to number; namen=1; %end; output; %end; run;%mend names;%names(x, 10000,100);2. 多种方法创建包含变量x的10000个观测值的sas数据集。
初值为0:data a; retain x 0; do i=1 to 10000; drop i;output; end; run;随机数:data a (drop=i); do i=1 to 10000; x=ranuni(0); output; end; run;读入其他数据文件:(先创建数据文件a,再从中读取)data a (drop=i); do i=1 to 10000; x=ranuni(0); output;file x:\a.txt; put x; end; run;data b;infile x:\a.txt; input x; output; run;读入其他数据集:data a;do i=1 to 10000; x=ranuni(0); output; end; run;data b; set a; drop i; output; run;3. 数据集a中日期变量date包含有缺失值,创建包含日期变量date的数据集b,并填充开始到结束日之间的所有日期值。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SAS综合练习题1. 今有某种型号的电池3批,他们分别是A,B,C,三个工厂所生产的,为评比其质量,各随机抽取5支电池为其样品,经实验的其寿命(小时)如下:A B C40 42 26 28 39 5048 45 34 32 40 5038 30 43试在显著性水平0.05下检验电池的平均寿命有无显著的差异,若差异是显著的,试求均值差是显著的,试求均值差ua-ub,ua-uc,及ub-uc的置信水平为95%的置信区间。
解:输入:data L1;Do type=1to3;Do rep=1to5;input x@@;output;end;end;cards;40 42 48 45 38 26 28 34 32 30 39 50 40 50 43Proc anova;class type;model x=type;run;输出:The SAS System 19:13 Sunday, April 18, 2011 1The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 2 615.6000000 307.8000000 17.07 0.0003Error 12 216.4000000 18.0333333Corrected Total 14 832.0000000R-Square Coeff Var Root MSE x Mean0.739904 10.88863 4.246567 39.00000Source DF Anova SS Mean Square F Value Pr > Ftype 2 615.6000000 307.8000000 17.07 0.0003 答:因为0.0003<0.05,所以拒绝假设A B C 组之间有显著性差异2,为了寻找飞机控制板上仪器表的最佳布置位置,试验了三个方案,观察员在紧急情况的反应时间(以1/10秒计),随机地选择28名领航员,得到他们对于不同的布置方案的反应时间如下:试在显著性水平0.05下检验各个方案的反应时间有无显著差异。
若有显著差异,试求u1-u2,u1-u3,u2-u3置信水平为0.95的置信区间输入:DATA L2;DO A=1TO3;INPUT N;DO J=1TO N;INPUT X@@;OUTPUT;END;END;CARDS;814 13 9 15 11 13 14 111210 12 7 11 8 12 9 10 13 9 10 9811 5 9 10 6 8 8 7;PROC GLM;CLASS A;MODEL X=A;RUN;输出:The SAS System 19:13 Sunday, April 18, 2011 3The GLM ProcedureDependent Variable: XSum ofSource DF Squares Mean Square F Value Pr > F Model 2 81.4285714 40.7142857 11.31 0.0003 Error 25 90.0000000 3.6000000Corrected Total 27 171.4285714The SAS System 19:53 Monday, April 19, 2010 2The GLM ProcedureDependent Variable: XSum ofSource DF Squares Mean Square F Value Pr > FModel 2 81.4285714 40.7142857 11.31 0.0003Error 25 90.0000000 3.6000000Corrected Total 27 171.4285714R-Square Coeff Var Root MSE X Mean0.475000 18.70643 1.897367 10.14286Source DF Type I SS Mean Square F Value Pr > FA 2 81.42857143 40.71428571 11.31 0.0003Source DF Type III SS Mean Square F Value Pr > FA 2 81.42857143 40.71428571 11.31 0.0003分析:方差分析得F=11.31.P=0.0003,按 =0.05的水准下,各个方案的反应时间有显著差异。
3. 某防治站对4个林场的松毛虫密度进行调查,每个林场调查五块地得资料如下表:地点松毛虫密度(头/标准地)A1192189176185190A2190201187196200A3188179191183194A4187180188175182判断4个林场松毛虫密度有无显著差异,取显著性水平α=0.05.输入:data a;do type=1to4;do rep=1to5;input x@@;output;end;end;cards;192 190 188 187189 201 179 180176 187 191 188185 196 183 175190 200 194 182proc anova;class type;model x=type;run;运行结果:The SAS System 19:14 Sunday, April 18, 2011 6The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 3 64.5500000 21.5166667 0.38 0.7699Error 16 910.0000000 56.8750000Corrected Total 19 974.5500000R-Square Coeff Var Root MSE x Mean0.066236 4.018946 7.541552 187.6500Source DF Anova SS Mean Square F Value Pr > Ftype 3 64.55000000 21.51666667 0.38 0.7699答:在 =0.05的显著水平下,0.7699>0.05,所以4个林场松毛虫密度没有显著差异4, 一实验用来比较4种不同药品解除外科手术后疼痛的延续时间(H),结果如下表:试在显著性水平a=0.05下检验各种药品对疼痛的延续时间有无显著差异。
输入:DATA L6;DO A=1TO4;INPUT N;DO J=1TO N;INPUT X@@;OUTPUT;END;END;CARDS;48 6 4 246 6 4 458 10 10 10 10 1234 4 2;PROC GLM;CLASS A;MODEL X=A;RUN;输出:The SAS System 19:13 Sunday, April 18, 2011 5The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 3 108.3333333 36.1111111 12.50 0.0005Error 12 34.6666667 2.8888889Corrected Total 15 143.0000000R-Square Coeff Var Root MSE x Mean0.757576 27.19477 1.699673 6.250000Source DF Anova SS Mean Square F Value Pr > Ftype 3 108.3333333 36.1111111 12.50 0.0005分析:因为0.0005<0.05,所以拒绝原假设,证明各种药品对解除疼痛时间存在显著差异。
5,将抗生素注入人体会产生抗生素与血浆蛋白质结合的现象,以致减少了药效,下表列出5种常用的抗生素注入到牛的体内时,抗生素与血浆蛋白质结合的百分比,试在水平a=0.05下检验这些百分比的均值有无显著的差异。
青霉素四环素链霉素红霉素氯霉素29.6 27.3 5.8 21.6 29.624.3 32.6 6.2 17.4 32.828.5 30.8 11.0 18.3 25.032.0 34.8 8.3 19.0 24.2试在显著性水平a=0.05下检验这些百分比的均值有无显著性差异。
输入:data L1;Do type=1to5;Do rep=1to4;input x@@;output;end;end;cards;29.6 24.3 28.5 32.027.3 32.6 30.8 34.85.86.2 11.0 8.321.6 17.4 18.3 19.029.2 32.8 25.0 24.2Proc anova;class type;model x=type;run;输出:The SAS System 19:13 Sunday, April 18, 2011 6The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 4 1480.823000 370.205750 40.88 <.0001Error 15 135.822500 9.054833Corrected Total 19 1616.645500R-Square Coeff Var Root MSE x Mean0.915985 13.12023 3.009125 22.93500Source DF Anova SS Mean Square F Value Pr > Ftype 4 1480.823000 370.205750 40.88 <.0001结果分析:因为0.0001<0.05,所以拒绝原假设,认为其各百分比有显著性差异。
6. 下表给出某种化工过程再三中浓度,四种温度水平下得率的数据试在水平a=0.05下检验,在不同浓度下得率的均值有无显著差异,在不同温度下得率的均值是否有显著差异,交互作用的效应是否显著输入:data l5;do a=1to3;do b=1to4;do i=1to2;input x@@;output;end;end;end;drop i;cards;14 10 11 11 13 9 10 129 7 10 8 7 11 6 105 11 13 14 12 13 14 10proc anova;class a b;model x=a b a*b;run;输出:The SAS System 19:13 Sunday, April 18, 2011 12The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 11 82.8333333 7.5303030 1.39 0.2895Error 12 65.0000000 5.4166667Corrected Total 23 147.8333333R-Square Coeff Var Root MSE x Mean0.560316 22.34278 2.327373 10.41667Source DF Anova SS Mean Square F Value Pr > Fa 2 44.33333333 22.16666667 4.09 0.0442b 3 11.50000000 3.83333333 0.71 0.5657a*b 6 27.00000000 4.50000000 0.83 0.5684答:因为pr a=0.0442<0.005,所以不同浓度的影响是显著的;由于pr b=0.5657 〉0.050,因为pr a*b=0.5684〉0.05,故温度的影响是不显著的,交互作用对均值的影响也不显著7. 为了研究金属管的防腐蚀的功能,考虑了4种不同的涂料涂层,将金属管埋没在3种不同性质的土壤中,经历了一定时间,测得金属管腐蚀的最大深度如下表所示(以mm计):失去水平=0.05检验在不同涂层下腐蚀的最大深度的平均值有无显著差异,设两因素间没有交互作用效应输入:data l2;do a=1to3;do b=1to4;input x@@;output;end;end;cards;1.63 1.35 1.271.34 1.30 1.221.19 1.14 1.271.30 1.09 1.32proc anova;class a b;model x=a b;run;输出:The SAS System 19:13 Sunday, April 18, 2011 5The ANOVA ProcedureDependent Variable: xSum ofSource DF Squares Mean Square F Value Pr > FModel 5 0.14981667 0.02996333 3.53 0.0780Error 6 0.05088333 0.00848056Corrected Total 11 0.20070000R-Square Coeff Var Root MSE x Mean0.746471 7.166532 0.092090 1.285000Source DF Anova SS Mean Square F Value Pr > Fa 2 0.07805000 0.03902500 4.60 0.0615b 3 0.07176667 0.02392222 2.82 0.1294答:因为pr a=0.0615>0.05, pr b=0.1294,所以涂层与土壤类型的均值无显著差异8.下表数据是退火温度x对黄铜延性Y效应的实验结果,Y是以延长度计算的画出散点图并求Y对于x的先行回归方程输入:data L8;input x y@@;cards;300 40 400 50 500 55 600 60 700 67 800 70proc plot;plot y*x="A";run;proc reg;model y=x;run;输出:The SAS System 19:13 Sunday, April 18, 2011 7The REG ProcedureModel: MODEL1Dependent Variable: yAnalysis of VarianceSum of MeanSource DF Squares Square F Value Pr > FModel 1 606.22857 606.22857 176.08 0.0002Error 4 13.77143 3.44286Corrected Total 5 620.00000Root MSE 1.85549 R-Square 0.9778Dependent Mean 57.00000 Adj R-Sq 0.9722Coeff Var 3.25525Parameter EstimatesParameter StandardVariable DF Estimate Error t Value Pr > |t|Intercept 1 24.62857 2.55441 9.64 0.0006x 1 0.05886 0.00444 13.27 0.0002Plot of y*x. Symbol used is 'A'.y ‚‚70 ˆ A‚‚‚A‚‚65 ˆ‚‚‚‚‚‚60 ˆ A‚‚‚‚‚‚55 ˆ A‚‚‚‚‚‚50 ˆ A‚‚‚‚‚‚45 ˆ‚‚‚‚‚‚40 ˆ A‚Šƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒˆƒƒ300 400 500 600 700 800答:解出所需方程为y=24.62857+0.05886x9. 在钢线炭含量对于电阻的效应的研究中,得到以下的数据:⑴画出散点图⑵求线性回归方程y=a+bx输入:data L1;input x y @@;cards;0.1 15 0.3 18 0.4 19 0.5 . 0.55 21 0.7 22.6 0.8 23.8 0.95 26proc plot;plot y*x;run;proc corr;var x y;proc reg;model y=x/cli clm clb;run;输出:The SAS System 19:13 Sunday, April 18, 2011 12Plot of y*x. Legend: A = 1 obs, B = 2 obs, etc.y ‚26 ˆA‚‚‚25 ˆ‚‚‚24 ˆ‚ A‚‚23 ˆ‚‚ A‚22 ˆ‚‚‚21 ˆ A‚‚‚20 ˆ‚‚‚19 ˆ A‚‚‚18 ˆ A‚‚‚17 ˆ‚‚‚16 ˆ‚‚‚15 ˆ AŠƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒƒƒˆƒƒ0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.45 0.50 0.55 0.60 0.65 0.70 0.75 0.80 0.85 0.90 0.95NOTE: 1 obs had missing values.The SAS System 19:13 Sunday, April 18, 2011 20The CORR Procedure2 Variables: x ySimple StatisticsVariable N Mean Std Dev Sum Minimum Maximumx 8 0.53750 0.27613 4.30000 0.10000 0.95000 y 7 20.77143 3.74242 145.40000 15.00000 26.00000Pearson Correlation CoefficientsProb > |r| under H0: Rho=0Number of Observationsx yx 1.00000 0.99871<.00018 7y 0.99871 1.00000<.00017 7The REG ProcedureModel: MODEL1Dependent Variable: yAnalysis of VarianceSum of MeanSource DF Squares Square F Value Pr > FModel 1 83.81831 83.81831 1940.48 <.0001Error 5 0.21597 0.04319Corrected Total 6 84.03429Root MSE 0.20783 R-Square 0.9974Dependent Mean 20.77143 Adj R-Sq 0.9969Coeff Var 1.00057Parameter EstimatesParameter StandardVariable DF Estimate Error t Value Pr > |t| 95% Confidence Limits Intercept 1 13.95839 0.17347 80.47 <.0001 13.51247 14.40430 x 1 12.55034 0.28491 44.05 <.0001 11.81796 13.2827119:13 Sunday, April 18, 2011 8The REG Procedure Model: MODEL1 Dependent Variable: yOutput StatisticsDep Var Predicted Std ErrorObs y Value Mean Predict 95% CL Mean 95% CL Predict Residual1 15.0000 15.2134 0.1486 14.8314 15.5955 14.5566 15.8702 -0.2134 2 18.0000 17.7235 0.1047 17.4544 17.9926 17.1253 18.3217 0.2765 3 19.0000 18.9785 0.0885 18.7511 19.2059 18.3979 19.5592 0.02154 . 20.2336 0.0795 20.0292 20.4379 19.6616 20.8056 . 5 21.0000 20.8611 0.0786 20.6591 21.0631 20.2899 21.4322 0.1389 6 22.6000 22.7436 0.0904 22.5112 22.9760 22.1610 23.3262 -0.14367 23.8000 23.9987 0.1074 23.7225 24.2748 23.3973 24.6000 -0.1987 8 26.0000 25.8812 0.1401 25.5211 26.2413 25.2369 26.5255 0.1188Sum of Residuals 0 Sum of Squared Residuals 0.21597 Predicted Residual SS (PRESS) 0.50730答:得回归方程:y=13.95839+12.55034x ;Pr<0.05 故回归效果显著,0432.0ˆ2=σb 的置信水平为0.95的置信区间(11.82,13.28) x =0.50处的值的置信水平为0.95 的置信区间为(20.03,20.44) x =0.50处的观测值置信水平为0.95的置信区间为(19.66,20.81)10 下表列出了18个5-8岁儿童的重量(这是容易测得的)和体积(这是难以测得的)⑴画出散点图⑵求Y关于x的先行回归方程y=a+bx输入:data L3;input x y @@;cards;17.1 16.7 10.5 10.4 13.8 13.5 15.7 15.7 11.9 11.6 10.4 10.2 15 14.5 16.0 15.8 17.8 17.615.8 15.2 15.1 14.8 12.1 11.9 18.4 18.3 17.1 16.7 16.7 16.6 16.5 15.9 15.1 15.1 15.1 14.5proc plot;plot y*x;run;proc reg;model y=x/cli;run;输出:The SAS System 19:13 Sunday, April 18, 2011 13The REG ProcedureModel: MODEL1Dependent Variable: yAnalysis of VarianceSum of MeanSource DF Squares Square F Value Pr > FModel 1 94.09987 94.09987 2311.89 <.0001 Error 16 0.65124 0.04070Corrected Total 17 94.75111Root MSE 0.20175 R-Square 0.9931Dependent Mean 14.72222 Adj R-Sq 0.9927Coeff Var 1.37037Parameter EstimatesParameter StandardVariable DF Estimate Error t Value Pr > |t|Intercept 1 -0.10405 0.31200 -0.33 0.7431x 1 0.98805 0.02055 48.08 <.0001The SAS System 19:13 Sunday, April 18, 2011 1516The REG ProcedureModel: MODEL1Dependent Variable: yOutput StatisticsDep Var Predicted Std ErrorObs y Value Mean Predict 95% CL Predict Residual1 16.7000 16.7916 0.0641 16.3429 17.2404 -0.09162 10.4000 10.2705 0.1041 9.7892 10.7517 0.12953 13.5000 13.5311 0.0536 13.0885 13.9736 -0.03114 15.7000 15.4084 0.0496 14.9679 15.8488 0.29165 11.6000 11.6538 0.0796 11.1940 12.1135 -0.05386 10.2000 10.1717 0.1059 9.6887 10.6547 0.02837 14.5000 14.7167 0.0476 14.2773 15.1561 -0.21678 15.8000 15.7048 0.0518 15.2632 16.1463 0.09529 17.6000 17.4833 0.0746 17.0273 17.9392 0.116710 15.2000 15.5072 0.0503 15.0664 15.9479 -0.307211 14.8000 14.8155 0.0476 14.3761 15.2550 -0.015512 11.9000 11.8514 0.0763 11.3941 12.3087 0.048613 18.3000 18.0761 0.0844 17.6125 18.5397 0.223914 16.7000 16.7916 0.0641 16.3429 17.2404 -0.091615 16.6000 16.3964 0.0589 15.9509 16.8420 0.203616 15.9000 16.1988 0.0566 15.7546 16.6430 -0.298817 15.1000 14.8155 0.0476 14.3761 15.2550 0.284518 14.5000 14.8155 0.0476 14.3761 15.2550 -0.315519 . 13.7287 0.0518 13.2871 14.1703 .Sum of Residuals 0Sum of Squared Residuals 0.65124Predicted Residual SS (PRESS) 0.77786答:回归方程为y= -0.10405+0.98805xx=14.0时的Y的置信水平为0.95 的预测区间为(13.29,14.17)11,蟋蟀用一个翅膀在另一个翅膀上快速的滑动,发出叫声,生物学家知道叫声的频率x与气温y具有线性关系,下列15对频率与气温间对应关系的结果试求Y关于x的线性回归方程试求Y关于x的线性回归方程输入:data L3;input x y @@;cards;20 31.4 16 22 19.8 34.1 18.4 29.1 17.1 27 15.5 24 14.7 20.917.1 27.8 15.4 20.8 16.2 28.5 15 26.4 17.2 28.1 16 27 17 28.614.4 24.6proc plot;plot y*x;run;proc reg;model y=x;run;输出:The SAS System 20:23 Sunday, April 18, 2011 13The REG ProcedureModel: MODEL1Dependent Variable: yAnalysis of VarianceSum of MeanSource DF Squares Square F Value Pr > FModel 1 136.41142 136.41142 30.20 0.0001Error 13 58.72591 4.51738Corrected Total 14 195.13733Root MSE 2.12541 R-Square 0.6991Dependent Mean 26.68667 Adj R-Sq 0.6759Coeff Var 7.96432Parameter EstimatesParameter StandardVariable DF Estimate Error t Value Pr > |t|Intercept 1 -3.85494 5.58491 -0.69 0.5022x 1 1.83396 0.33374 5.50 0.0001答:所得线性回归方程为y=-3.85494+1.8339612,下面列出了自1952——2004年各界奥林匹克运动会男子10000米赛跑的冠军成绩,1,求Y关于x的线性回归方程下面列出了自1952——2004年各界奥林匹克运动会男子10000米赛跑的冠军成绩,1.求Y关于x的线性回归方程输入:data L1;input x y @@;cards;1952 29.3 1956 28.8 1960 28.5 1964 28.4 1968 29.4 1972 27.6 1976 27.71980 27.7 1984 27.8 1988 27.4 1992 27.8 1996 27.1 2000 27.3 2004 27.1 2008 .proc reg;model y=x/cli clm clb;run;输出:The SAS System 19:13 Sunday, April 18, 2011 1The REG ProcedureModel: MODEL1Dependent Variable: yAnalysis of VarianceSum of MeanSource DF Squares Square F Value Pr > FModel 1 5.58647 5.58647 33.47 <.0001Error 12 2.00281 0.16690Corrected Total 13 7.58929Root MSE 0.40854 R-Square 0.7361Dependent Mean 27.99286 Adj R-Sq 0.7141Coeff Var 1.45943Parameter EstimatesParameter StandardVariable DF Estimate Error t Value Pr > |t| 95% Confidence Limits Intercept 1 105.48264 13.39429 7.88 <.0001 76.29899 134.66628 x 1 -0.03918 0.00677 -5.79 <.0001 -0.05393 -0.02442The SAS System 19:13 Sunday, April 18, 2011 1The REG Procedure Model: MODEL1 Dependent Variable: yOutput StatisticsDep Var Predicted Std ErrorObs y Value Mean Predict 95% CL Mean 95% CL Predict Residual1 29.3000 29.0114 0.2072 28.5601 29.4628 28.0134 30.0095 0.2886 2 28.8000 28.8547 0.1847 28.4523 29.2572 27.8779 29.8316 -0.0547 3 28.5000 28.6980 0.1636 28.3415 29.0546 27.7391 29.6569 -0.19804 28.4000 28.5413 0.1446 28.2263 28.8564 27.5971 29.4856 -0.14135 29.4000 28.3846 0.1285 28.1047 28.6645 27.4515 29.3177 1.0154 6 27.6000 28.2279 0.1165 27.9741 28.4817 27.3023 29.1535 -0.6279 7 27.7000 28.0712 0.1100 27.8315 28.3109 27.1494 28.9930 -0.37128 27.7000 27.9145 0.1100 27.6748 28.1542 26.9927 28.8363 -0.21459 27.8000 27.7578 0.1165 27.5040 28.0116 26.8322 28.6834 0.0422 10 27.4000 27.6011 0.1285 27.3212 27.8810 26.6680 28.5342 -0.2011 11 27.8000 27.4444 0.1446 27.1293 27.7594 26.5002 28.3886 0.3556 12 27.1000 27.2877 0.1636 26.9312 27.6442 26.3288 28.2466 -0.1877 13 27.3000 27.1310 0.1847 26.7286 27.5334 26.1541 28.1079 0.1690 14 27.1000 26.9743 0.2072 26.5229 27.4257 25.9763 27.9723 0.1257 15 . 26.8176 0.2306 26.3151 27.3201 25.7954 27.8397 .Sum of Residuals 0 Sum of Squared Residuals 2.00281 Predicted Residual SS (PRESS) 2.52888答:回归方程为x y0392.04826.105ˆ-=, Pr > F ,<.0001,所以回归效果显著,预测2008年成绩为26.82min 。