BASE机经变形题总结

更新时间:2024-01-05 13:49:02 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

3/3/2015

(109) QUESTION 109

The contents of the raw data file EMPLOYEE are listed below: ----|----10---|----20---|----30 Ruth 39 11 Jose 32 22 Sue 30 33

John 40 44

The following SAS program is submitted: data test;

in file' employee';

input employee_ name $ 1-4;

if employee_ name = 'Sue' then input age 7-8; else input idnum 10-11; run;

Which one of the following values does the variable AGE contain when the name of the employee is \

A. 30 B. 33 C. 40

D. . (missing numeric value)

QUESTION 110

The contents of the raw data file EMPLOYEE are listed below: ----|----10---|----20---|----30 Ruth 39 11 Jose 32 22 Sue 30 33

John 40 44

The following SAS program is submitted: data test;

in file' employee';

input employee_ name $ 1-4;

if employee_ name = 'Ruthh' then input idnum 10-11; else input age 7-8; run

Which one of the following values does the variable IDNUM contain when the name of the employee is \Ruth\

A. 11

B. 22 (33) C. 32

D. . (missing numeric value)

Answer: B

机经:

正如各位前辈所言,70以及变形一定要看。今天考到的有:

4,13,16,17,20,21(gt 50),22,24,30,31,32,34,35(output变为else output),40(do while (prod le 6)改为(do until(prod gt 6))),42(变为填空,US放在了最前面),46,47,51,53,56,57,60,61,63,65,66(在第一个end后面加了output,求X值),67(if X<10 then X=1改为X=3),69,70(题目改为根据log内容,判断错误内容)

70题的变型全部考到,全新题在7-8题

1)The following SAS program is submitted:

data WORK.TOTAL;

set WORK.SALARY; by Department Gender;

if First.<_insert_code_> then Payroll=0;

Payroll+Wagerate;

if Last.<_insert_code_>; run;

The SAS data set WORK.SALARY is currently ordered by Gender within Department.

Which inserted code will accumulate subtotals for each Gender within Department? A. Gender _insert_code_ _insert_code_ B. Department

C. Gender Department D. Department Gender

Answer: A

18.Which statement describes a

characteristic of the SAS

automatic

variable _ERROR_?

A. The _ERROR_ variable maintains a count of the number of data errors in a DATA step.

B. The _ERROR_ variable is added to the program data vector and becomes part of

the data set being created.

C. The _ERROR_ variable can be only used in expressions in the DATA step. D. The

_ERROR_ variable contains the number of the

observation

that caused the

data error .

Answer: C

9)The following SAS program is submitted:

proc format;

value score 1 - 50 = 'Fail' 51 - 100 = 'Pass'; run;

proc report data = work.courses nowd; column exam;

define exam / display format = score.; run;

The variable EXAM has a value of 50.5.

How will the EXAM variable value be displayed in the REPORT procedure output? A. Fail B. Pass C. 50.5

D. . (missing numeric value)

答案:C

19) TheSAS data set WORK.ONE contains a numeric variable named Num and a character variable named Char:

WORK.ONE

Num Char --- ---- 1 23 3 23 1 77

The following SAS program is submitted:

proc print data=WORK.ONE;

where Num='1'; Num=contain(1); 没contain这个函数 run;

What is output? A.

Num Char --- ----

1 23 B.

Num Char --- ---- 1 23 1 77

C.

Num Char

--- ---- 1 23 3 23 1 77

D. No output is generated.

Answer: D (num+char, where statment can not work)

21)Given the SAS data set WORK.PRODUCTS:

ProdId

Price ProductType Sales Returns

------ ----- ----------- ----- -------

K12S 95.50 OUTDOOR 15 2

B132S 2.99 CLOTHING 300 10

R18KY2 51.99 EQUIPMENT 25 5

3KL8BY 6.39 OUTDOOR 125 15

DY65DW 5.60 OUTDOOR 45 5

DGTY23 34.55 EQUIPMENT 67 2

The following SAS program is submitted:

data WORK.OUTDOOR WORK.CLOTH WORK.EQUIP;

set WORK.PRODUCTS; if Sales GT 50;

if ProductType

EQ 'OUTDOOR' then output WORK.OUTDOOR; else if ProductType

EQ 'CLOTHING' then output WORK.CLOTH;

else if ProductType

EQ 'EQUIPMENT' then output WORK.EQUIP; run;

How many observations does the WORK.OUTDOOR data set contain? A. 1 B. 2 C. 3 D. 6

Answer: B

27.Given the SAS data set WORK.TEMPS:

Day Month Temp

--- ----- ----

1 May 75 15 May 70 15 June 80 3 June 76 2 July 85

14 July 89

The following program is submitted:

proc sort data=WORK.TEMPS;

by descending Month Day by day descending Month; run;

proc print data=WORK.TEMPS; run;

Which output Is correct?

33) The following SAS program is submitted:

data WORK.TEST; set WORK.PILOTS;

if Jobcode='Pilot2' then Description='Senior Pilot'; else Description='Unknown'; run; The value for the variable Jobcode is:

PILOT2.What is the

value of the variable Description? A. PILOT2 B. Unknown C. Senior Pilot

D. ' ' (missing character value)

Answer: B

35) x y 5 2

1 3 5 6

题目改成了,

if x=5 then output one; if y lt 5 then output two; else output other;

How many observations in each dataset? 答案是 2 for one, 2 for two, 1 for other. 35) given the SAS data set SASDATA.TWO: X Y -- -- 5 2 3 1

5 6

The following SAS program is submitted: data SASUSER.ONE SASUSER.TWO OTHER; set SASDATA.TWO; if X eq 5 then output SASUSER.ONE; if Y lt 5 then output SASUSER.TWO; else output; run;

What is the result?

A.

data set SASUSER.ONE has 5 observations

data set SASUSER.TWO has 5 observations data set WORK.OTHER has 3 observations B.

data set SASUSER.ONE has 2 observations

data set SASUSER.TWO has 2 observations data set WORK.OTHER has 1 observations

C.

data set SASUSER.ONE has 2 observations

data set SASUSER.TWO has 2 observations data set WORK.OTHER has 5 observations

D. No data sets are output.

The DATA step fails execution due to syntax errors.

Answer: A

36) Given the contents of the raw data file 'EMPLOYEE.TXT':

----+----10---+----20---+----30-- Xing 19 2 2004 ACCT Bob 5 22 2004 MKTG Jorge 3 14 2004 EDUC

The following SAS program is submitted:

data WORK.EMPLOYEE;

infile 'EMPLOYEE.TXT'; input

@1 FirstName $ @15 StartDate

@25 Department $; run;

Which SAS informat correctly completes the program? A. date9.

B. mmddyy10. C. ddmmyy10. D. mondayyr10.

Answer: B

42) The following SAS program is submitted:

data WORK.ONE;

Text='US-Austrilia Denmark'; Pos=find(Text,'US','i',5); run;

What value will SAS assign to Pos? A. 0 B. 1 C. 2 D. 12

Answer: D

填空题,给出find(‘US-Austrilia....', 'US', 'i', 5) 的具体数值,答案是填 5 (在8字符里面)

44) The following SAS program is submitted:

data ONE TWO SASUSER.TWO;

set SASUSER.ONE; run;

Assuming that

SASUSER.ONE exists, how many

temporary and

permanent SAS data

sets are created?

A. 2 temporary and 1 permanent

SAS data sets are created B. 3 temporary and 2 permanent

SAS data sets are created C. 2 temporary and 2 permanent

SAS data sets are created D. there is an error

and no new data sets are created

Answer: D

46) Given the SAS data set WORK.ONE:

Obs Revenue2007 Revenue2008 Revenue2009 Revenue2010 --- ----------- ----------- ----------- 1 1.2 1.6 2.0

The following SAS program is submitted:

data WORK.TWO; set WORK.ONE;

Total=mean(of Rev:); run;

What value will SAS assign to Total? A. 3

B. 1.6 C. 4.8

D. The program fails to execute due to errors. Revenue2007 对应的值为 . 计算的平均值

选项变成了 A. . B. 1.0 C.1.6 D.The program fails to execute due to errors.

Answer: B

52.Given the SAS data set WORK.EMP_NAME:

Name EmpID ---- ----- Jill 1864 Jack 2121 Joan 4698 John 5463

Given the SAS data set WORK.EMP_DEPT:

EmpID Department

1.2 1.6 2.0 . ----- ----------

2121 Accounting 3567 Finance 4698 Marketing

xxxxxxxxxxxxxxx

5463 Accounting

The following program is submitted: data WORK.ALL;

merge WORK.EMP_NAME(in=Emp_N)

WORK.EMP_DEPT(in=Emp_D); by Empid;

if (Emp_N and not Emp_D) or (Emp_D and not Emp_N); run;

How many observations are in data set WORK.ALL after submitting the program? A. 1 B. 2 C. 3 D. 5

52) Given the SAS data set WORK.EMP_NAME:

Name EmpID ---- ----- Jill 1864 Jack 2121 Joan 4698

John 5463 注意它变了!Emp_N里面有两个不在Emp_D里,所以最后选3.

Given the SAS data set WORK.EMP_DEPT:

EmpID Department ----- ----------

2121 Accounting 3567 Finance 4698 Marketing

5463 Accounting

The following program is submitted:

data WORK.ALL;

merge WORK.EMP_NAME(in=Emp_N)

WORK.EMP_DEPT(in=Emp_D); by Empid;

if (Emp_N and not Emp_D) or (Emp_D and not Emp_N); run;

How many observations(填空) are in data set WORK.ALL after submitting the program? A. 1 B. 2 C. 3 D. 5

55.The following SAS program is submitted:

data WORK.DATE_INFO;

X=\ run;

Variable X contains what value?

A. the numeric value 0

B. the character value \ C. the date value 01011960

D. the code contains a syntax error and does not execute.

Answer: D

57) Given the SAS data set WORK.ONE:

N BeginDate - ---------

1 09JAN2010

2 12JAN2010

The following SAS program is submitted:

data WORK.TWO; set WORK.ONE;

Day=<_insert_code_>;

format BeginDate date9.; run;

The data set WORK.TWO is created, where Day would be 1 for Sunday, 2 for Monday, 3 for Tuesday, ... :

WORK.TWO

N BeginDate Day

- --------- ---

1 09JAN2010 1

2 12JAN2010 4

Which expression successfully completed the program and creates the variable Day?

A. day(BeginDate) 果然变成了输出日期,所以是day() B. weekday(BeginDate) C. dayofweek(BeginDate)

D. getday(BeginDate,today())

Answer: B

60)Given the SAS data set WORK.PRODUCTS:

ProdId

Price ProductType Sales Returns

------ ----- ----------- ----- -------

K12S 95.50 OUTDOOR 15 2

B132S 2.99 CLOTHING 300 10

R18KY2 51.99 EQUIPMENT 25 5

3KL8BY 6.39 OUTDOOR 125 15

DY65DW 5.60 OUTDOOR 45 5

DGTY23 34.55 EQUIPMENT 67 2

The following SAS program is submitted:

data WORK.REVENUE(drop=Sales Returns Price);

set WORK.PRODUCTS(keep=ProdId Price Sales Returns);

Revenue=Price*(Sales-Returns); run;

How many variables does the WORK.REVENUE data set contain? A. 2

B. 3 C. 4 D. 6

Answer: A

66)The following SAS program is submitted:

data WORK.SALES;

do Year=1 to 5;

do Month=1 to 12;

X + 1; Output=60 end; Output=5 end; run;

How many observations(填空) are written to the WORK.SALES data set? A. 0 B. 1

C. 5

D. 60

Answer: B

output的位置不同,答案也不同。我在SAS里跑过,应该是这样的: (1) do var1=1 to 7; do var2 = 1 to 12; X+1; output;

end; end; run;

输出7*12=84个observation

(2) do var1=1 to 7; do var2 = 1 to 12; X+1; end;

output; end; run;

输出7个observation

(3) do var1=1 to 7; do var2 = 1 to 12; X+1; end;

end; output; run;

输出1个observation

67) Consider the following data step:

data WORK.NEW;

set WORK.OLD(keep=X); if X < 10 then X=3;

else if X >= 10 AND X LT 20 then X=2;

else X=1; run;

In filtering the values of the variable X in data set WORK.OLD, what value new value would be assigned to X if its original value was a missing value?

A. X would get a value of 1. B. X would get a value of 3.

C. X would retain its original value of missing.

D. This step does not run because of syntax errors.

Answer: A

变成了if X<10 then X=3; else X=1; 所以选3.

寂静:

1.proc contents data=sasuser._all_ 后面要加个什么语句,才能suppresses the printing of detailed information about each file in the output;

NODETAILS

2. put(date, worddate20.)如之前总结的,选 put(date, worddate20.) April 15, 1999

3.split=“*”

一个data步中有一个label里面是这样的“xxxxx*xxxx*xxxx”,想在真正的label中*变空格,叫你选语句填空.类似“cat*dog”这样的格式,怎样实现将*指定为分隔符,实际输出“cat dog”的形式呢?答案选split=“*”

4.几个有效的dataset name DATA

WORK.one -test ( test_ 2Test

好像还有几个不记得了

但是最后答案是一共4个有效

SAS data set names 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.

5.how many data sets can be combined when using APPEND statement? 2

Adds the observations from one SAS data set to the end of another SAS data set. only two data sets can be combined at one time, a BASE data set and a DATA data set.

6.sort by

填空题还有一道是填语句的,我只记得是考的by语句和acsending descending什么的,不难,题目看清哪个变量在前面就行。

7.Error, datalines缺分号

8.option yearcutoff=1920

给你两个date9.的日期,一个是20结尾,一个是19结尾,为你像个日期相减是多少,我选的-99

9.一道题考的是_N_配合if语句选输出

10.do i=1 to 7; do i=1 to 10; x+1; end; output; end;

run;

问结果输出多少条observations(注意output的位置,我填的7)

11.还有一道考了ods pdf,水的一逼,其它选项都没有ods,什么open啦之类的,细心点就行 ods

html

file='HTML-file-pathname';

ods

pdf

file='PDF-file-pathname';

proc

print

data=sasuser.admit; run;

ods _all_ close; ods listing;

One of the features of ODS is that you can produce output in multiple formats concurrently by opening each ODS destination at the beginning of the program.

When you have more than one open ODS destination, you can use the keyword _ALL_ in the ODS CLOSE statement to close all open destinations concurrently.

12.infile xxxxxx missover;

var1 var2 var3 var4

var5 /*注意这里故意漏掉了符号?/dataline是(全是人名地点什么的字符):xxx,xxx,xxx,xxx,xxxxxxx,xxxx,xxxx,xxxx,xxxx,xxxxxxx,xxxx,xxxx,xxxx,xxxx问你如果后面加一个变量等于error,数据输出是怎样的?我选的那一列是1,0,0,1,因为execute的时候要出错只有第一行和最后一行会出错,当中两行因为missover就不会涉及到那个错误定义的变量吧。不知道这个答案对不对,心里也没底。13.end也考了,不过比较简单,答案选114.input数据的题大概题意是这样的:原始数据heu,afvf,salefsrbtbtf,gg,humanresourceahviu,fvfet,saledatatest;infile′原始数据‘dlm=′,′missover;inputvar110. vat2:10. var3:20.; run;

You can use the MISSOVER option in an INFILE statement to prevent SAS from reading the next record when missing values are encountered at the end of a record.

26.有work.b,其中变量Char为字符15长。 data a;

length Char 20; set b;format Char $15.;

run; 问Char最终在work.a里面的length为多少

其实要区分format概念和length概念,length还是最初声明的20,format不改变其length。

25.给一组data 里面有三个variable 是numeric 两个是character 然后问 array arrayname{*}= _number_; 这个create了几个new variables a)0

b)1 c)2 d)3 e)error 0

23.原来70题里面的Num='1'替换成contain(1),答案不变,contain没这个函数。

22.考察了libname用法以及libref的规则,我就记得最后在libname test_1 '_SAS_lib_location_', 和libname testdatablabla '_SAS_lib_location_' 里犹豫,后来选test_1是valid name,因为 libref is a shortcut name or a \are stored. It is any SAS name when you are assigning a new libref. When you are disassociating a libref from a SAS library or when you are listing attributes, specify a libref that was previously assigned.

libref is 1 to 8 characters long, begins with a letter or underscore, and contains only letters, numbers, or underscores

21.有一个数据集n,其中变量a20.

data m; length a 15 set n;

format a 25.; run;

问 a的length.

我选的是15,因为length a 15,不确定。。

1、一个数据集,告诉你某个变量长度为10,然后先用length定义为15,再用format 设为20,问最终输出的长度

20.我觉得retain考得挺多的,关键记住如果没有specify initial value(就像这样 retain test_var), 那么默认为missing.还有就是retain只在complie阶段运行,到了execution阶段就没他什么事了

General form, simple RETAIN statement for initializing accumulator variables: RETAIN variable initial-value;

where

! variable is a variable whose values you want to retain

! initial-value specifies an initial value (numeric or character) for the preceding variable.

Note The RETAIN statement

! is a compile-time only statement that creates variables if they do not

already exist

! initializes the retained variable to missing before the first execution of the

DATA step if you do not supply an initial value

! has no effect on variables that are read with SET, MERGE, or UPDATE

statements. (The SET and MERGE statements are discussed in later chapters.)

See retain questions.

19.

数据集a中,加入array a(3)_temporary_,问a中包含几个变量? A. _temporary_1 _temporary_2 _temporary_3 B. a_1 a_2 a_3 C. a1 a2 a3 D. no variable 这一题我记的问得类似是这样:

data test;

array a{3}_temporary_; run;

问数据集test中有几个变量,我选了d, 因为如下:

Creating Temporary Array Elements

You can create temporary array elements for DATA step processing without creating additional variables. Just specify _TEMPORARY_ after the array name and dimension. This is useful when the array is needed only to perform a calculation. Temporary是对了 但是没有后面1-3的数字

16. dim具体不记得题了~

array big{5} weight sex height state city; do i=1 to dim(big);

more SAS statements; end;

17.[size=13.63636302948px]campress()函数

大概意思如下,数据自己编的: data test;

x=1234 45-78 898; y=compress(x, '-');

run;

我就记得两个选项一个是:12344578898 另一个是:1234 4578 898

我也不会这道题就随便选了后面那个选项~ a='AB C D '; b=compress(a); put b; ABCD

----+----1----+----2----+----3

x='123-4567-8901 B 234-5678-9012 c'; y=compress(x,'ABCD','l'); put y;

123-4567-8901 234-5678-9012

----+----1

x='1 2 3 4 5'; y=compress(x,,'s'); put y; 12345

----+----1

x='Math A English B Physics A'; y=compress(x,'ABCD','k'); put y;

ABA

15.cat() 函数题的大意为:

data test;do I = 'SUN', 'MON', 'TUES';

weekday=cat(i, 'DAY');

run;

问在output中weekday的值。

我这道题是填空题~

Does not remove leading or trailing blanks, and returns a concatenated character string. data _null_;

x=' The 2002 Olym'; y='pic Arts Festi';

z=' val included works by D '; a='ale Chihuly.'; result=cat(x,y,z,a); put result char.; run;

SAS writes the following line to the log:

----+----1----+----2----+----3----+----4----+----5----+----6----+----7 The 2002 Olympic Arts Festi val included works by D ale Chihuly.

9.有一个题目是reading instream data,系统报错停止,让你分析原因,我选的是datalines后面忘记分号

变形题:

40)The following SAS program is submitted:

data WORK.PRODUCTS; Prod=1;

do until(prod gt 6) 先执行,再判断;

Prod + 1 (执行2); end; run;

What is the value of the variable Prod in the output data set?

A. 6 B. 7 C. 8

D. . (missing numeric)

Answer: B

QUESTION 101

The following SAS program is submitted: proc freq data=sales;

run:

Exhibit: output from the FREQ procedure.

Which one of the following statements completes the program and produces the output?

A. tables region product; B. tables region* product; C. tables product region;

D. tables product region*;

Answer: B

1) 用means的时候,关于missing values是怎么处理的?

选项大概是Use only all non-missing values; Use all non-missing values and numbers stored as char variables; ... Proc means ...

For each variable, the number of non-missing values are used.

2) proc print data = work.student ???; label ID = 'StudentID'

INFO = 'Major*GPA*Units';run; a) labelsplit = '*'; b) split = '*';

PROC PRINT sometimes conserves spaceby splitting labels across multiple lines. Use SPLIT= in the PROC PRINT statementto control where these splits occur. You do not need to use LABEL if you useSPLIT=. 没有labelsplit

? 3. data errors when you read raw data from ... a) writes a note in SAS log and continue to execution b) writes a error in SAS log and suspend to execution c) writes notes in SAS log until the errors limit ...

d) writes a warning in SAS log and suspend to execution

Data errors occur when some data values are not appropriate for the SAS statements thatyou have specified in the program. For example, if you define a variable asnumeric, but the data value is actually character, SAS generates a data error.SAS detects data errors during program execution and continues to executethe program, and does the following:

? writes an invalid data note to the SAS log.

? prints the input line and columnnumbers thatcontain the invalid value in the SAS log. Unprintable characters appear in hexadecimal. To help determine column numbers, SAS prints a rule line abovethe input line.

?

?

sets the automatic variable _ERROR_ to 1 for thecurrent observation.

一个是用BY statement写出都是ASCENDING的语句。

valid variable个数

_test test_ test21 test_21

70题有考weekday(begindate),今天考了dayofmonth(begindate)

ods pdf file主要还是考ods的 还有csv还是cvs的也有

2. data test1;

set test2 end=eof; input var1; var1=eof; run;

问var1值是多少? 答案1

有一道end=eof(1(当前观察值是最后一个)/0(当前观察值不是最后一个)) 问最后一个obs的值是多少 有451 missing 0 1 我蒙的1 有会的可以普度众生一下

1. 关于year cutoff那题, 我后面有d, 所以我选了missing没有选2060. 如果有人有不同意见欢迎讨论 yearcutoff=1970; Date='01jan60'd; Year=year(date); 1.

prints the observation under the rule line.

yearcutoff=1970; Date='01jan60'; Year=year(date);

问:what is the value of Year? 选项有 1960, 2060, ... 我选了2060 yearcutoff=1970

理解yearcutoff的意义即可。题目中60必须是1970之后,我选2060年

3. 关于_ERROR_

如果选项里有The _ERROR_ variable can be used in expressions or calculations in the DATA step. 那么一定选这个

我遇到的不是的,是The _ERROR_ variable can only be used in expressions in the DATA step. 所以没选

选的类似这个 _ERROR_ signals the occurrence of an error that is caused by the data during execution. (这句是书上的)我的那个是有contain的。还有一个选项跟这个很像但是是maintain ,大家去翻翻书把定义巩固一下

4. 这题大家一定要记住! 要不上场看到死磕C跟D,像我一样

data WORK.NEW; set WORK.OLD; Count+1; run;

The varaible Count is created using a sum statement. Which statement regarding this variable is true?

A. It is assigned a value 0 when the data step begins execution.

B. It is assigned a value of missing when the data step begins execution. C. It is assigned a value 0 at compile time.

D. It is assigned a value of missing at compile time. Answer: C

2.

Proc contents data=work._all_; run;

Several statemens are listed for selection. 我选了D, ...list all the data set files in Work library and each file's metadata.

------------------------------------------------------------------ 43.Given the SAS data set WORK.ORDERS:

WORK.ORDERS

order_id customer shipped

-------- ------------ ---------

9341 Josh Martin 02FEB2009

9874 Rachel Lords 14MAR2009

10233 Takashi Sato 07JUL2009 The variable order_id is

numeric; customer is

character; and shipped

is

numeric,

contains a SAS date value,and is shown with the DATE9. format.

A programmer would like to create a new variable, ship_note,that shows a character value with the order_id,shipped date, and customer name.

For example, given the first observation ship_note would have the value \ shipped on 02FEB2009 to Josh Martin\

Which of the

following statement will

correctly create the value and assign it to

ship_note? A.

ship_note=catx('

','Order',order_id,'shipped

on',input(shipped,date9.),'to',customer); B.

ship_note=catx('

','Order',order_id,'shipped

on',char(shipped,date9.),'to',customer); C.

ship_note=catx('

','Order',order_id,'shipped

on',transwrd(shipped,date9.),'to',customer);

D. ship_note=catx(' ','Order',order_id,'shipped on',put(shipped,date9.),'to',customer);

Answer: D

原来dataset中numeric变量Ship_date表示如 17 Mar 1999(这里日期随便写的, 格式是一样的),问以下哪个语句将Ship_date改成如 March 17 1999这样的字符数据。答案应该是 Ship_date_char=put (Ship_date, worddate20.);

4、新考点五:worddate20.

有一个题,要求把日期输出成这个样子:\这题之前看到其他帖子介绍了,是个新提。于是背答案了。

四个选项中有两个是 input( ),有两个是put( ),显然input( )是错的,于是在 put( ) 里面二选一:

A) put(date, date9., worddate20.) B) put(date, worddate20.) B为正确答案。

@填空题,给出含有IDNumber和Expenses两个变量的dataset, 写出code 要求ascending Expenses within ascending IDNumber.

答案是 by IDNumer Expenses (题目将结尾;在空白后面已给出)

@新题:

表的名字都不记得了,随便编的,不过题目的基本结构都是准确的。

1. 有一个数据表叫temp1,里面有EmpID, Name, Dept. 有50个observation

还有一个数据表叫temp2, 里面有EmployeeID (注意这里变量名不一样), Name, Dept. 有4个observation 然后程序是 data temp;

set temp1 temp2;

run;

问最后输出多少个observation? 选项有50, 4, missing和error。我选的是error因为我觉得没有by。不确定,欢迎大家讨论。 我刚去考了了。题是问 how many variables in output.

答案是4;

data temp1; length empid 8dept8 salary 8; input empid dept salary ;

cards; abcd IT 3000 bcef HR 2000

cccc Eng 3999 ; run; proc print data=temp1;run;

data temp2; length id 8dept8 salary 8; input id dept salary ;

cards; abcd IT 3001 ; run; proc print data=temp2;run;

data both; set temp1 temp2; run; proc print data=both;run;

2. data new; Amount =4; If Amount=4

then word=\ If Amount=7

then word=\ Else if word=\ Amount=7; run;

问最后输出的结果是什么? 我选的是Amount=7, word=FOUR。不确定,欢迎讨论。

array items{3} _TEMPORARY_ 选项是

ITEMS1,ITEMS2,ITEMS3 ITEMS_1,ITEMS_2,ITEMS_3

_TEMPORARY_1,_TEMPORARY_2,_TEMPORARY_3 这题我不大确定

6、其他帖子也见过的新题

label split=

we want to wrap the label AAAA*BBBB,选哪个?

A) wrap='*' B) split='*'

C) labelwrap='*' D) label='*' B为正确答案

@有個 retain 但沒有給初始值 然後跑 XXX=xx+xxxx 的迴圈 问输出结果,這題答案不確定

3、if _N_=1 then total=xx+xxxx

xx和xxxx都是之前input后面读入的,total一开始retain 为0,后面就是这个if语句,最后问输出结果

@对于libref的命名规则也考了,问你以下4个选项有几个是符合规则的。

libref is 1 to 8 characters long, begins with a letter or underscore, and contains only letters, numbers, or underscores.

1. ods html file=\ proc one... proc two...

run;

ods pdf close;

兩個 proc 但只有1個run

不確定是答案甚麼,但回家後隨便試了兩個proc,雖有error message,但是能輸出html結果

新考点四:data set 的名字

问以下六个data set 的名字,正确的有多少个? 我选了四个。

data set的名字不能超过32个字符,以字母和下划线开始等等要求。

4. LENGTH的用法一定要搞清楚

有道题是说DATASET里面给出了length为13,然后FILE确定的是10,最后程序写出的是9 差不多类似这种,就是不要被搞混了

1, 问variable length是多少?

先给出num length是10, 然后在data step中设length是15, 再用format把variable变成length 20, 问 variable length是多少?

这里要区分format概念和length概念,format不改变其length。

29.The following SAS program issumbitted: data WORK.INFO;

infile'DATAFILE.TXT'; input @1 Company 20.@25State2.@; if State=' ' theninput @30 Year; else input @30City Year; inputNumEmployees;

run; How many raw data records areread duringeach iteration of the DATA step? A. 1 B. 2 C. 3 D. 4

原始答案A, 正确答案是B.

2, 问你以下4个选项有几个是符合规则的 work. one two _two 2_two

注意libref is 1 to 8 characters long, beginswith a letter or underscore, and contains only letters, numbers, orunderscores.

另外,ODS输出考了PDF输出。

@给了一个label,类似“cat*dog”这样的格式,怎样实现将*指定为分隔符,实际输出“cat dog”的形式呢?答案选split=\

@在数据集a中,加入array a(3)_temporary_,问a中包含几个变量? 给出的选项为:A. _temporary_1 _temporary_2 _temporary_3 B. a_1 a_2 a_3 C. a1 a2 a3 D. no variable

data a;

input a $ b c; retain z;

if _n_=1 then z=0; else z=b+c; datalines; x 50 25

y 25 15 z 30 35 ;

问最后的output结果是什么样的

@有個 retain 但沒有給初始值 然後跑 XXX=xx+xxxx 的迴圈 问输出结果,這題答案不確定

3、if _N_=1 then total=xx+xxxx

xx和xxxx都是之前input后面读入的,total一开始retain 为0,后面就是这个if语句,最后问输出结果

6. 选项是Program Data Vector那个表,就是看_error_,这个肯定不是0就是1,而且前面有1后面不会变成0

3. 问proc means可以处理的数据是什么 选项有

non-missing numbers

missing and non-missing numbers

non-missing numbers and numbers in character form

missing and non-missing numbers and numbers in character form

By default, PROC MEANS computes the n-count (the number of non-missing values), the mean, the standard deviation, and the minimum and maximum values for variables. 大概这个意思

我不确定选什么,知道的人说下呗~

1. 选哪一个可以创建comma delimited file(CSV)我选的程序是

ods cvsall file=... ...

ods cvsall close;

没有ods cvs的选项,而且其他感觉都不太对,有一个是open cvs file=...这样的,感觉不对吧?

2. 计算人口增长,每年增2%,结果要是每年年份和相应的人口数量 我选的好像是

do year=*** to ***; ...*1.02 output; end;

大概这样的

(填空题)一题问proc sort中by ascending var1 within ascending var2的by statement 怎么写,也很简单,就是by var2 var1,并且我遇到填空中的分号已经给在空格后面了,所以千万要看清楚,不要重复写了。

第一题,如果要输出pdf怎么写,选这个(真题是输出cvs,那个我也考到了,一样的,就是改成

cvsall),其他选项很明显不对,要不就是缺了file=什么的

ods pdf file='asdfghjkl'; ........

ods pdf close;

第二题,proc contents data=要读xlsx文件,格式和sas表格不一样,貌似那个机经提起过,我顺便背了一下,刚好用到了,就选答案看起来最复杂的那个,‘data'n好像是,请自行google

第三题,如果2012年人口是34,896,280,数字随便写的,每年增长2%,要求最后人口,出来dataset效果要是每年的数据写一个obs,问程序长什么样,这里选项只有两个地方不一样,都是do loop写的,一个是do year=2012 to 2021;这一句要对,还有loop中间要output;才能保证每年都有输出。

第四题, data work.one;

set work.two; ...

total=total+var1; ... run;

题干给了data长啥样,有2个variable,好像是id和amount,提问work.one长啥样,和.two长一样,只不过多了一列total。但是这里total没有retain,也不是total+var1;所以是missing value,于是每个observation的total值都是'.'

第五题,考yearcutoff options yearcutoff=1920; data work.one; dateA='01JAN19'd; yearA=year(dateA); dateB='01JAN20'd; yearB=year(dateB);

diff=yearb-yearA; run;

问diff等于几,答案-99

第六题,考_N_和_ERROR_

先给出一个raw data,全是名词,词记不得了,形式没错,大概长这样 john,lily,lucy,andrews,jay friend,year

hill,mountain,daisy,rose score,play,ball

文件名如果叫temp,给出以下程序 data work.one;

file temp dlm=',' missover;

input name1name2 var1 var2 var3 ; run;

问每一步中的_N_和_ERROR_值分别是多少,_N_就是1,2,3,4,5,这个不会有问题,就是当前第几步,_ERROR_要注意了,如果开始是0,一旦有错就变成1切保持为1,这里第一步就出错了,因为读数据是第五个变量漏了,值变成missing,_ERROR_也变成了1,之后每一步都是1了。

1. label split='*';

多了个revenue2007 值是missing

考的X=\问x值

改问是每月的第几天,选day(begindate) 变成dificount{3} diff1-diff3; 4.

一个dataset,列出了所有的variables的类型 Name Type N1 num N2 num N3 char

N4 char

问在程序中array{*} _numeric_ 建立了几个variable

答案是0, 因为这条命令只是refer了dataset里所有num类型的variables,并没有建立新的变量 5.

如果今天是Jan 2, 1960 问today() 答案应该是1

寂静:有一道题

data set a, 3 varibales Name length 10 age length 8 some length 8

data b;

length name $ 15; set data=a; run;

问name的length

10和15纠结了很久最后选了15,不知对错

2)put (date, worddate20.) 这个 3)split='*’

4)if employee_name=\这个,选的是22.因为没有@,所以input移向下一行选择。

5)哪几个是valid data set name, work.one,data这两个比较迷惑。 6)where=contain 这个。 机经 8/27/14

大多数题在95题库中,答案的顺序有变化。下面-题有点变化。 How many of the below data names will be valid ? WORK.ONE name

_name_

2name2 #name _name#

a) 0 b) 2 c) 3 d) 6

2060 那题出现,前面有人提过。

SAS考试最新机经和新题型探讨 length a 15 set n; format a $25.; run; 问 a的length.

我选的是15,因为length a 15,不确定。。

9. put(date, date9., worddate20.)

put(date, worddate20.)如之前总结的,选 put(date, worddate20.) 机经8/19/14

1、70题是绝对的法宝,crackman的解析真是极好的。因为大部分是原题,老美也是好懒,连数字都不换一换,甚至题目的表述、答案的选项都不变,唯一换一换就是答案的顺序。不过,我遇到两个填空,但也是70题上面的,merge in=的那道题,还有一个是20题,输出三个文件,outdoor那个。所以,最坏最坏,实在看不懂的70题,把答案记住也行!或者,你做的非常熟练了,估计题目没看完就知道选什么!呵呵,当然谨慎期间,还是好好看题。

2、贡献一个新题,是我看了之前很多机经没有发现的,或许我自己漏掉了。

给出一个叫deduction 的dataset 的contents,让你看到有2个charateristic 3个numeric 变量。然后下面写了一个data step, 大致是 data xxx; set deduction;

array dudec{*} _numeric_;

问你这个新的data里有几个变量? A 1 B 0 C 3

D 没有,因为出错。

我一开始选的d,后来选的c,实在不知道是什么,请指教! 3、其他几道70题没有的题

如果你看了其他几篇机经,可以发现大家说的新题都是一样的,有

1)_error_ 的性质,有一个选项是:_error_ can only be used in expression in data step;还有一个选项是:_error_ is used to cound the number of data error in data step.差不多是这样,我觉得这两个比较迷惑。

本文来源:https://www.bwwdw.com/article/mlrx.html

Top