注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
今天刚考完,867低调水过。之前看了地里的两份机经受益匪浅,链接如下:https://www.1point3acres.com/bbs/thread-538815-1-1.html.--
https://www.1point3acres.com/bbs/thread-538477-1-1.html
饮水思源,和大家分享一下今天考试内容。.--
-baidu 1point3acres
本大佬0基础复习了十天,复习资料就是70题 (harrison59题https://worldwall.info/tag/70题/ 以及流传甚广的70题)以及sas support搜索关键词。
先给想考sas的朋友吃一颗定心丸,过关不难,本垃圾十天下来应该说还完全没能领悟sas精髓,但即使这样应付考试也问题不大了。
选择的考点是上海同济对面,环境还行机器捉急。考试模式已经有人总结过了,再赘述一遍,9个lab,前7个自己码,后两个给了有bug的代码需要改。每个lab根据code运行结果回答2-4小问,每问2-3分。lab之后是和改革前形式一样的选择/填空,每题1分。今天一共考了lab21问,填空选择21问,合计42问。下面开始回忆,并给出本大佬的一些解答。本垃圾相信这些解答绝大部份都不是最优解,抛砖引玉欢迎讨论。. 1point 3acres
在考试之前需要做setup,指定两个libs:
libname cert '...';
libname results '...'; 物理路径不记得了,有提示照抄
lab1: Given a dataset cert.input01 with several variables (ID, Posal_code, income, etc.). Build a new dataset results.output01 based on given dataset, only keep the observations with highest income for each Postal_code.
本大佬认为:sas似乎没有根据条件删除上一条observation的指令,所以此处本垃圾建了一个临时dataset Temp01, 记录每个Postal_code中的最高income:
data Temp01;. .и
set cert.input01;
by Postal_code;
retain theHigh;
if first.Postal_code then theHigh = 0;
else if income GT theHigh then theHigh = income;
if last.Postal_code then output;. check 1point3acres for more.
run;
然后merge临时表格Temp01和cert.input01建立results.output01,每一行如果income等于theHigh则保留,否则删除。本垃圾认为这个方法属实很蠢,仅供更菜的参考。
lab2: Merge two datasets with common variable. One dataset contains variables Product and Qty, another contains variables Product and Price.
本大佬认为:题目中会要求在新的dataset中新建一个variable名叫total, total = Qty * Price.
lab3: Use libname statement to import an excel file. Figure its worksheets' names.
本大佬认为:简单地使用如下代码:
libname MYEXCEL '...';.
proc contents MYEXCEL._all_;
run;
在结果中找到sheets的名称。然后使用:
proc contents MYEXCEL.sheetname;
run;. From 1point 3acres bbs
即可查看特定worksheet中包含的内容,回答相关问题。
.--
lab4: Given a dataset and output its observations to three subsets based on conditions (age).
本大佬认为:简单地使用:
data results.output04Young results.output04Mid results.output04Old. 1point3acres.com
set cert.input04;
if age LE 35 then output results.output04Young;
else if age LE 60 then output results.output04Mid;
else output results.output04Old;
run;
然后proc freq或者proc means 处理新得到的subsets回答相关问题。
lab5: Given a data set cert.input05 which is students' roster. One variable is 'major' and it may contain things like 'Physics', 'History and Math' or 'Statistics and Computer Science'. If an 'and' is included then put the first major into 'major' and put the second one into 'second major'.
本大佬认为:题目中的major和second major不一定是一个词,如'computer science' 所以scan不好用,需要用find找出关键词and,来判断是否对特定observation进行substr处理,使用如下代码:
data results.output05;
set cert.input05;.
State = upcase(State);
locationOfAnd = find(major,'and');
if locationOfAnd NE 0 then do;. Χ
secondMajor = substr(major, locationOfAnd + 4);
major = substr(major, 1, locationOfAnd - 2);
end;. .и
run;
需要注意的是,在这种方法中secondMajor的赋值需要在major重新赋值之前进行。本垃圾认为这个方法属实很蠢,仅供更菜的参考。.google и
本题中还问了所有学生来自多少不同的State?使用如下代码:
proc sort data = results.output05 out = sort05;
by State;
run;
data countState;
set sort05;
by State;
if first.State; ..
run;
本题中还问了如何去除variable name开头为特定字符串的columns, (比如去除variable name开头为abc的columns 使用如下option选项:
. From 1point 3acres bbs(drop = abc:). Waral dи,
本题中还问了有多少学生来自NC州,大二年级,并且没有second major?
那么需要根据条件进行筛选,State = 'NC', year = 'Soph', missing(secondMajor). 值得注意的是,不能使用多个where语句,这样只会保留最后一个where,之前的where不起作用。
lab6 和 lab7 恕本垃圾都不记得了。
lab8 改错。新增一个变量group,需要根据age来给group赋值,错误代码中没有在之前length.
lab9 改错。忘掉是什么题目了,但题目中有大量变量名大小写不统一的错误,比如一处是Balabala下一处写成了balabala,我要改瞎了。还有部分if then do else方面的逻辑错误,需要理解要求进行修改。
Lab到此为止,last but not least,给予一些小的建议:
- 题目中会有大量的问题是关于某个dataset第多少个obs的某个变量是啥。可能有些朋友在自己电脑操练的时候,去output选项卡拉一拉进度条看一看很方便,但是考试电脑的窗口很小,电脑不顺畅,所以这样做很吃力。尽量根据问题中的obs编号,使用proc print在选项中为firstobs和obs赋同一个值,然后在results选项卡中直接看比较快。
- 考试的机器中打开input的dataset查看结构很不方便,除非实在有问题就别看了。
- 考试的机器打字有一定的延时,莫慌,慢慢打。
- 某一个lab耗时多很正常,也莫慌
选择题和填空题基本都来自70题原题,新增的知识点包括macro和proc transpose.
-macro只需简单地记住,(假设叫xxx)
赋值:%let xxx = value,
引用:if something GT &xxx,
作为libref:&xxx..someDateset
-根据不多的机经和我的考试,Transpose必考两题,
ID的使用是为了避免variable names变成col1, col2... . ----
Var的使用是因为sas会自动transpose数值型变量,而不会transpose字符型变量。当需要transpose字符型变量时使用var指定。 ..
祝大家考试顺利。
我今天遇到一个妹子很漂亮,考试坐我对面。我打算考完了和她交流一番,没想到她半个小时就考结束了,我扎扎实实做了俩小时。tmd.
..
|