查看: 7839| 回复: 13
跳转到指定楼层
上一主题 下一主题
收起左侧

[其他] SAS ADV 10/14 onsite 971 分过经

全局:

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看附件。没有帐号?注册账号

x
本帖最后由 heresoutheast 于 2020-10-15 06:53 编辑

感谢论坛小伙伴之前分享的机经,这次考试顺利,顺便也把自己准备考试搜集的资料和经验分享下,希望后来者看到有用,以下进入正题。. 1point3acres

一、考前电脑与环境准备(这次考试太折腾了,全在这一步,给大家做参考)
1. 关闭windows 自动更新
我第一次base 考试是选择了在家,一切都顺利,所以这次考adv 所以也选择了在家。但是,临到考试那天,考前准备登陆系统,windows 就开始自动更新了,这就尴尬大了,早不更新晚不更新,偏偏就在考前二十分钟开始。看着时间一分一分过去,更新的贼慢,于是赶紧联系在线客服。最后,赶在开考前把考试时间改到了第二天。老Windows平时不怎么用,这下系统更新花了几个小时。. ----
.1point3acres
由此,强烈建议各位在家考试的朋友,先把windows 自动更新关闭;如果平时用mac临时用windows,最好提前让它运行下,有更新也可以提前更新。

2. 测试系统地点和实际考试地点最好一致
因为第一次考base 过程非常顺利,用同样的电脑,在同样的地方,连同样的网,我想应该都没问题的,结果还是意外不断。

Reschedule的考试我例行测试系统时在客厅完成的,第二次考试那天搬到自己房间后,结果不知咋的,网速不正常,系统测试一直通不过。我第一次考base 都好好的呀,咋回事。最后把门打开,挪动电脑,终于测试通过。但很不幸的是,onVUE时不时就现实断线,没法跟监考人员沟通。于是再次联系客服,这次已经到了开考时间点,不能修改预约时间了,只能反应问题。最后经过多方沟通,在电话指导下,我被允许挪到客厅重新进入系统。 ..

由此,强烈建议考前在自己准备考试的地方测试系统。

3. 在家or onsite
后来好不容易在客厅接入系统,兴致勃勃的准备开考,结果在introdiction 界面虚拟机一直在加载,始终黑屏,在线跟监考人员反应了一次又一次,各种方法试过,就是不行。最后,只能报issue,考试被中断。 ..
两天后,得到通知被允许再免费预约一次,有了之前的经历,心理阴影较深,最后选择onsite。今天现场去,两个考场,每个考场只能同时有2人考试,全程戴口罩。

所以如果没有windows 或者windows 很老担心出问题,去onsite 应该也行。

二、考试题目(后面我贴出我平时准备时练习的代码,接近原题,基本包括考试的所有题型)
我遇到的Project:
SQL
1. 从一个表中读name,要求name必须在另一个表的name中
   select name from a
   where name in (select name from b);

2. 从一个表中选 unique Make and Type, 从另一个表中匹配Rebate,有对应的Make 和 Type 则显示Rebate,否则为空。我自己用left join 做的。
. .и
select distinct c.Make, c.Type, r.Rebate from table1 c left join table2 r on
c.Make=r.Make and c.Type=r.Type

3. 从一个表中选择某一列并取平均值,将这个平均值给一个宏变量。
..
4. 从一个表中选某列的平均值,附加一些一些条件,并做排序。. From 1point 3acres bbs


Mac 类
1. %Check(10)
前面我加了 options mprint symbolgen
我选的 parameter 为 ‘N’, 第二问我填的 age. 1point 3 acres
2.  写一个含有comment的macro(comment的内容不能执行),
  后面macro的内容是一个proc print的语句,最后执行这个macro. 1point 3 acres

3.用sql把region='AMR'的avg(var)存成一个macro variable

Array 类. Χ
1. inch to centimeters

2. 所有的missing value 全部变成0

3.写一个array LS,有LENGTH1-LENGTH3, 另外一个array NEW,NEWLENGTH1-NEWLENGTH3. 有一个data set,LS单位是in,NEW是换算后的cm,NEW(i)=2.54*LS(i)

Functions 类. check 1point3acres for more.
1. Inch to Centimeters

Hash类
1. 建立hash,对某个数据集查找符合项,有则输出到info19,没有则输出到errors19


选择填空题:
基本都来自63。
1. 有个填空题,大概是

%let xyz=5;
%let mn= 6;
%macro xx;
   %let abc=7;
   %put ?????
%mend;
. 1point3acres%xx;
. From 1point 3acres bbs
问 填入什么可以显示
. global xyz
global mn
global abc

我填的 _user_,不知道对不对。. 1point3acres.com


2. 删除宏变量
%symdel xx;
.1point3acres
3. 显示current date
选 worddate. 那个

4. 怎么读出某个libray 下的所有table. Χ
我选的
select memname from dictionary.tables . 1point 3 acres

三、我用到的非常有用的参考资料

https://www.1point3acres.com/bbs/thread-672473-1-1.html
https://www.1point3acres.com/bbs/thread-596537-1-1.html
https://www.1point3acres.com/bbs/thread-662271-1-1.html. 1point 3acres
https://www.1point3acres.com/bbs/thread-599568-1-1.html
https://www.1point3acres.com/bbs/thread-653645-1-1.html
https://www.1point3acres.com/bbs/thread-672473-1-1.html
https://www.1point3acres.com/bbs/thread-582546-1-1.html
https://www.1point3acres.com/bbs/thread-626388-1-1.html
https://www.1point3acres.com/bbs/thread-633891-1-1.html
https://www.1point3acres.com/bbs/thread-614570-1-1.html
https://www.1point3acres.com/bbs/thread-599641-1-1.html
https://www.1point3acres.com/bbs/thread-644116-1-1.html.
https://www.1point3acres.com/bbs/thread-642710-1-1.html
https://www.1point3acres.com/bbs/thread-640176-1-1.html
https://www.1point3acres.com/bbs/thread-645429-1-1.html-baidu 1point3acres
https://www.1point3acres.com/bbs/thread-645095-1-1.html
https://www.1point3acres.com/bbs/thread-653665-1-1.html
https://www.1point3acres.com/bbs/thread-650342-1-1.html.google  и
https://www.1point3acres.com/bbs/thread-653645-1-1.html
https://www.1point3acres.com/bbs ... %3D92%26typeid%3D92. 1point 3acres
. Waral dи,

四、我参考上述机经后准备的练习代码,应对考试题型基本没啥问题,数据在附件中,自己建一个也可以。
另外,强烈建议考前做以下那个practice,很有帮助
/*********************************************************************************
Prepare data
X1 and X2 are used as inputs.
/*********************************************************************************/
libname cert '/folders/myfolders/Certification_SAS for beginners_SAS codes/Cert_base/input/';

libname new xlsx '/folders/myfolders/Certification_SAS for beginners_SAS codes/Cert_base/input/input01.xlsx';

libname out  '/folders/myfolders/Certification_SAS for beginners_SAS codes/Cert_base/output/';.


data x1;
set new.sheetc;
run;

data x2;
set new.sheeta;
run;


proc sql;
select * from dictionary.indexes
where libname=’SASUSER’ and memname=’SALE2000’;
quit;

/*********************************************************************************. ----
Macro
/*********************************************************************************/
/*---------------------------------------------
  Macro Exmple 1
  一道问用什么option debug %check15,然后问var是什么,这个仔细读log就可以了
  这个有两问:
1. positional paramete
2.里面data set 中if作用的variable是什么,这个就得%check15(10),我记得variable应该是age.
两道题,问parameter的是N;问variabne的是age
----------------------------------------------*/

options mprint mlogic;
macro %check15(10);

. Waral dи,

/*---------------------------------------------
  Macro Exmple 2
  用sql把region='AMR'的avg(var)存成一个macro variable
----------------------------------------------*/
proc sql;
Select avg(score) into: avg_score
From x1
Where region^='';
Quit;
.
%put &avg_score;

.
/*---------------------------------------------
  Macro Exmple 3
  建一个maro,在do loop里面写一个if语句;
----------------------------------------------*/
/*Style 1*/
%macro loop(start,end);
%do i= &start %to &end;
  data data&i;
   x=&i;
%end;
%mend;

%loop(1,3);


/*Style 2*/
%macro loop(begin,end);
%do i =&begin %to &end;
   %if &i>10 %then %do;
    data x&i;. ----
        x=&i;
        run;
        %end;
%end;. Waral dи,
%mend;
%loop(1,12);.--


/*---------------------------------------------
  Macro Exmple 4
  1)%eval()是取整,但是只能进行整数运算
  浮点运算用 %sysevalf()比如%let a=%sysevalf(&a+2.333333);
  2) 写一个macro,定义一个global variable x,initial value是1.25,
  用do while或者do until,increment 0.25 ,一直到2
----------------------------------------------*/

/* Method 1: do until */-baidu 1point3acres

/* %let x=1.25; */
%macro lnc;
%let x=1.25;
%do %until (&x>2);
  %let x=%sysevalf(&x+0.25);
  %put &x;-baidu 1point3acres
%end;
%mend;

%lnc;
.google  и

/* Method 2: do while */
%macro loop;
%global x;
%let x=1.25;
%do %while (&x<2);
%let x=%sysevalf(&x+0.25);
%put &x;
%end;. check 1point3acres for more.
%mend;

%loop;



/*---------------------------------------------
  Macro Exmple 5
  写一个含有comment的macro(comment的内容不能执行),.
  后面macro的内容是一个proc print的语句,最后执行这个macro
----------------------------------------------*/
%macro xx;
  /*%put ERROR- xx;*/
  proc print data=xxx;. 1point3acres.com
%mend;

%xx;



/*********************************************************************************/
/*Function*/.google  и
/*********************************************************************************/
/*---------------------------------------------
  Function Exmple 1
  proc fcmp IN to CM, 建好function后options cmplib=work.functions,然后建个新data里面
  有个新列newheight=IN to CM(height)cm=2.45IN
----------------------------------------------*/. 1point3acres.com

proc fcmp outlib=work.functions.dev;. 1point 3 acres
function in2cm(in);
  return(in*2.54);
  endsub;

options cmplib=work.functions;
-baidu 1point3acres
Data ACT03;
Set x1;
NewHeight=in2cm(height);
Run;



/*---------------------------------------------.google  и
  Function Exmple 2
  Weight change: lbs to kg
----------------------------------------------*/
proc fcmp outlib=work.a.c;
Function l2k(l);
k=0.9*l;
return(k);
endsub;.google  и
run;
. .и
options cmplib=work.a;
data x2;
set x1;
new_weight=l2k(weight);.
run;



/*---------------------------------------------
  Function Exmple 3
  String as input.  数据集需要添加name= first name + second name,没时间就没加
----------------------------------------------*/
options cmplib=(work.functions);. ----
proc fcmp outlib=work.functions.dev;
function ReverseName(name $) $ ;
  length newname $40;
  newname=catx(' ',scan(name,2,','),scan(name,1,','));
  return (newname);.google  и
  endsub;

data xx;
set yy;.1point3acres
  zz=ReverseName(Name);
run;


/*********************************************************************************
Array.--
https://support.sas.com/resource ... s/sugi30/242-30.pdf
*********************************************************************************/
/*---------------------------------------------
  Arrary Exmple 1
. check 1point3acres for more.  Change all missing value to 0
----------------------------------------------*/
data new;
set x1;
array var(*) _numeric_;
do i=1 to dim(var);
if var(i)=. then var(i)=0;
end;
drop i;
run; ..
        



/*---------------------------------------------.
  Arrary Exmple 2
  把q1-q3的A,B,C,D,E换成1,2,3,4,5存在num1-num3中
----------------------------------------------*/
data new2;.
set x1;
array q(3) q1-q3;
array num(3) num1-num3;
do i=1 to 3;
if q(i)='A' then num(i)=1;
else if q(i)='B' then num(i)=2;
Else If  q{i}='C' then num(i)=3;
Else If  q{i}='D' then num(i)=4;. Waral dи,
Else If  q(i)='E' then num(i)=5;

end;
run;
..

. From 1point 3acres bbs
/*---------------------------------------------.google  и
  Arrary Exmple 3
  写一个array LS,有LENGTH1-LENGTH3, 另外一个array NEW,NEWLENGTH1-NEWLENGTH3.
  有一个data set,LS单位是in,NEW是换算后的cm,NEW(i)=2.54*LS(i)
----------------------------------------------*/. From 1point 3acres bbs
data ls;
set x1;
array ls(*) LENGTH1-LENGTH3;
array new(*) NEWLENGTH1-NEWLENGTH3;
do i =1 to 3;
NEW(i)=2.54*LS(i);
end;
drop i;
run;

. 1point 3acres

/*********************************************************************************/
/*SQL*/
/*********************************************************************************/
/*---------------------------------------------
  SQL Exmple 1 .google  и
  ----------------------------------------------*/
Proc sql;.1point3acres
Create table sql01 as
Select *. Χ
From x1
Where name in (select name from x2);
Quit;


/*---------------------------------------------
  SQL Exmple 2
  在PROC SQL里面创建一个新的Variable,case expression:
----------------------------------------------*/
.--

proc sql;
create table new_table as
select name, height, case
when height >=180 then 'high'
when height >=170 and height <180 then 'middle'
when height <170 then 'low'
end as height_marker from x1;. check 1point3acres for more.
quit;. 1point 3 acres
. ----


/*---------------------------------------------
  SQL Exmple 3 . From 1point 3acres bbs
use SQL to create a new table that contains all unique values of Make and Type
from cert.cars, and Rebate from cert.rebate. For Rebate, show Make and Type if matching;
if no matching Make and Type, show missing. Only three variable: Make, Type, Rebate
  ----------------------------------------------*/
proc sql;. Waral dи,
select  distinct x2.name, height, gender, benefit from x1 right join x2 on. check 1point3acres for more.
x1.name=x2.name;
quit; ..
. ----
-baidu 1point3acres

/*---------------------------------------------
  SQL Exmple 4.--
  给选出来的变量加label (select x label="foo", y)
  ----------------------------------------------*/.
proc sql;
select name label='Student Name', n1 label='Index1' from x1;
quit;


/*---------------------------------------------
  SQL Exmple 5
  having avg大于150 用department进行分组,按着一个variable进行sort
  ----------------------------------------------*/
proc sql;

create table xx as
select department, avg(height) as hei from x1
group by department. ----
having hei>150. 1point3acres
order by department;
quit;
.--
.google  и

/*---------------------------------------------
  SQL Exmple 6
  Use dictionary.columns to get the list of variable name of a table.1point3acres
  ----------------------------------------------*/

proc sql;
select name into: collist separated by ','
from dictionary.columns
. 1point3acreswhere libname='WORK' and memname='X1' and name like '%ght';
quit;.1point3acres

%put &collist;
. From 1point 3acres bbs

. Χ

/*********************************************************************************/
/*Hash Object*/
/*********************************************************************************/. 1point 3acres

/*---------------------------------------------
  Hash Exmple 1
  Hash 根据country19建立hash表,然后input contry20,根据key查表,成功的输出work.XXX,
  失败的输出到work.errors。(这道题我到现在还百思不得其解,考的时候完全按照机经写的,run的时候
  log说population没有被define?!在scoreit()里面run得时候给了response code 708
  也不知道是不是对的。)
----------------------------------------------*/

Data info19 errors19;
Length country name $30;
If _n_=1 then do;
Declare hash C(dataset:'cert.country19');
C.definekey('name');
C.definedata('population');
C.definedone();
Call missing (country,name);
end;. ----

set cert.country12;
rc=c.find(); /*rc=return code*/
if rc=0 then output info19;
else output errors19;
run;. .и


/*---------------------------------------------
  Hash Exmple 2 .1point3acres
----------------------------------------------*/.1point3acres
data hash_sample;
input fruit$ amount;
cards;. 1point3acres
apple  100. check 1point3acres for more.
orange 200
tomato 300
cherry 400
cherry 500
;
run;
-baidu 1point3acres

data _null_;
length fruit $10. amount 8.;
if _n_ = 1 then do ;

/*Declare Hash Object*/
declare hash myhash (dataset:'hash_sample',duplicate:'r');/*Replace the duplicate, only keep the last one*/
rc = myhash.definekey('fruit');
rc = myhash.definedata('fruit','amount');
rc = myhash.definedone();

call missing(fruit,amount); /*When no matching values, return none*/ ..

end;
.1point3acres
/*Check*/. 1point 3 acres
rc=myhash.find(key:'cherry'); /*find if cherry exist*/
if rc=0 then do; /*rc=0: find cherry*/
put fruit= amount= ;
end;.

/*Check and Replace*/
rc=myhash.check(key:'tomato');
if rc=0 then do;
  put 'tomato is exist';
  rc = myhash.replace(key:'tomato',data:'tomato',data:350);
end;

/*Find and put*/
rc=myhash.find(key:'tomato');
if rc=0 then do;. Χ
put 'new tomato' fruit= amount= ;. Χ
end;

/*Add a record*/
myhash.add(key:'peach',data:'peach',data:400);/*add new vaule*/
rc=myhash.find(key:'peach');.--
if rc=0 then do;
put 'new peach' fruit= amount= ;
end;.1point3acres
-baidu 1point3acres
/*If not exist, then add; otherwise keep it*/
myhash.ref(key:'balabala',data:'balabala',data:600);
rc = myhash.find(key:'balabala');
if rc=0 then do;
put 'balbala' fruit= amount= ;. Χ
end;
. From 1point 3acres bbs
/*Total number of records*/
totalitems = myhash.num_items;/*totalitems*/. 1point 3acres
put  totalitems;
myhash.output(dataset:'out');/*Put data into 'out' dataset*/
run;


data success fail;
length name $10;
call missing(name);
if _n_=1 then do;
  declare hash c(dataset:'xxx');
  c.definekey(yy);
  c.definedata(zz,name);. 1point3acres.com
  c.definedone();
end;

set dajl;. 1point 3acres
if c.find() then output success;
else output fail;
run;


. 1point3acres



/*---------------------------------------------
  Hash Exmple 3 .google  и
----------------------------------------------*/
. 1point3acres
data work.success work.fail;    /* 建立题目要你建立的dataset */. ----
   drop rc;                                  /*后面要用rc做查找,所以这里drop一下,跟你做do loop的时候drop i是一个意思*/
length YYName $30;               /* YYName是你的definedata,很多时候原来没有,你得建立变量 */   
if _N_=1 then do;                    /* 固定格式不谈*/   
call missing (YYName);          /*你的YYName不是刚刚建立的吗,空的不行,所以你得用这个call missing初始化他*/
declare hash C(dataset:'x1');           /* 声明你的hash表,hash名字和dataset一定会给你,记得单引号 */   
c.definekey('ID');                     /* 定义你的hash key,就是那个ID,key在题目里,记得单引号 */
c.definedata('YYName');         /* 定义你的hash data ,就是那个YYName在题目里,一般就是我们刚刚Length的那货 */     -baidu 1point3acres
c.definedone();                       /* hash定义完的声明,固定格式*/   
end;                                      /*这里是end上面那个do的,还记得有个do吗朋友*/-baidu 1point3acres
..
set cert.planes;                       /* 这里是你要去用你刚刚建立的hash表查找的另一个表,跟定义hash的表不同 */   
rc=c.find();                              /* 你可以理解为哈希表的查找结果,如果RC=0,就说明查找成功,这个cert.planes里面有哈希表这样一个对应关系,如果rc不等于0 ,说明没有*/
   if rc=0 then output work.success;       /* 如果rc=0,查找成功,那么就输出成功表 */   
   if rc ne 0 then output work.fail;         /* 如果rc不等于0,查找失败,那么就输出失败表 */
run;
-baidu 1point3acres

input01.xlsx

11.96 KB, 下载次数: 22, 下载积分: 大米 -1 颗

评分

参与人数 3大米 +19 收起 理由
bluecloudszy + 2 很有用的信息!
uuuuu7 + 2 给你点个赞!
pikado + 15 欢迎分享你知道的情况,会给更多积分奖励!

查看全部评分


上一篇:学了python还有有必要去学SAS吗?
下一篇:SAS Base 10/14/2020 956pass
推荐
az267 2021-3-5 12:58:00 | 只看该作者
全局:
子明(Five) 发表于 2020-11-10 08:08
请问“写一个含有comment的macro(macro的内容不能执行),”这句话是什么意思啊?看了您总结的机经这块还 ...

在sas中写一句话如果把它comment掉,sas是不会执行这句话的。
例如: ..
data ABC;
/*data DEF;*/
我把第二行用 /*  */ 给comment掉了,SAS就不会执行它了,只执行上面一句 data ABC;
回复

使用道具 举报

推荐
 楼主| heresoutheast 2020-11-10 09:41:51 | 只看该作者
全局:
子明(Five) 发表于 2020-11-10 08:08
请问“写一个含有comment的macro(macro的内容不能执行),”这句话是什么意思啊?看了您总结的机经这块还 ...

我理解为:写一个macro,macro 里有一句是被注释掉而不能执行的语句,这个语句是题目给定的

评分

参与人数 1大米 +1 收起 理由
子明(Five) + 1 赞一个

查看全部评分

回复

使用道具 举报

推荐
 楼主| heresoutheast 2020-10-17 05:40:08 | 只看该作者
全局:
轻声飞 发表于 2020-10-16 00:40. 1point3acres
谢谢楼主分享,总结得非常全面!想问下您写的第四部分自己准备的练习代码,是都考过的吗?还是您延伸的,比 ...
..
练习代码是我根据其他人分享机经 + 模拟测试 总结的
回复

使用道具 举报

全局:
感谢楼主,跟你同天考试过的base,准备考adv
回复

使用道具 举报

全局:
谢谢楼主分享,总结得非常全面!想问下您写的第四部分自己准备的练习代码,是都考过的吗?还是您延伸的,比如:fcmp中的reversename,比如use dictionary.column,比如hash example2 example2。因为在您提供的参考链接中没有发现。其中use dictionary.column这个考点其他人分享的jj中好像没有提到过。期待回复~
回复

使用道具 举报

全局:
请问“写一个含有comment的macro(macro的内容不能执行),”这句话是什么意思啊?看了您总结的机经这块还是没看懂
回复

使用道具 举报

🔗
uuuuu7 2020-11-10 09:30:23 | 只看该作者
全局:
congra!
三里看到了自己的帖子嘿嘿
回复

使用道具 举报

🔗
 楼主| heresoutheast 2020-11-10 09:42:22 | 只看该作者
全局:
uuuuu7 发表于 2020-11-10 09:30
congra!
三里看到了自己的帖子嘿嘿

赞!谢谢之前的分享!
回复

使用道具 举报

全局:
好的,大概明白了,所以题目解答里用/* ……*/。谢谢
回复

使用道具 举报

🔗
saonibaba 2020-12-27 09:50:58 | 只看该作者
全局:
楼主hash example 3里面应该也可以用双引号吧,我看书里面有的example用单引号有的用双引号
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册账号
隐私提醒:
  • ☑ 禁止发布广告,拉群,贴个人联系方式:找人请去🔗同学同事飞友,拉群请去🔗拉群结伴,广告请去🔗跳蚤市场,和 🔗租房广告|找室友
  • ☑ 论坛内容在发帖 30 分钟内可以编辑,过后则不能删帖。为防止被骚扰甚至人肉,不要公开留微信等联系方式,如有需求请以论坛私信方式发送。
  • ☑ 干货版块可免费使用 🔗超级匿名:面经(美国面经、中国面经、数科面经、PM面经),抖包袱(美国、中国)和录取汇报、定位选校版
  • ☑ 查阅全站 🔗各种匿名方法

本版积分规则

>
快速回复 返回顶部 返回列表