SAS_Adv最强机经.pdf - 我的机经补充 left join and...

This preview shows page 1 - 5 out of 25 pages.

我的机经补充 left join and in-line view Product Product_id Product 1 1001 2 1002 3 1003 Sales Product_id Sales 3 100 1 200 5 100 1 200 3 100 1 100 Proc sql; Select p.product s.totalsales From product as p left join ( select sum(sales) as totalsales from sales as s) on p.product_id=s.product_id; quit; What is the output? Answer: Product Totalsales 1001 500 1002 . 1003 200 No.4 from 63 题库 干扰选项 :into group separate=’,’ 正确选项 into :GROUPS separated by ',' 关于 view 考了三道题, (1)哪个个 view 的命名 code 正确?data xxx/ view=xxx (view 和 data set 的命名必须一样) (2)q.11 变型,改了 data set 命名,并且只生成一个 data set。选项原理木有改。
Image of page 1

Subscribe to view the full document.

(2)生成了 view 之后在 proc mean 中如何引用?和普通 data set 一样。(后面机经总结中也有) Proc sort data=xxx Nodupkey;By var; 考了三道 (1)q.45 题目明确 unsorted data set, 所以 first 那个不能用 (2)给了 data set 和 desired output,要求选 code。 发现是要生成 unique value of key variable. 只有 proc sort nodupkey; by var 的选项对,有干扰选项 proc sort nodup; by var; (3)后面机经中提到的 q.45 变型 I in-line view 另外还考了一道题,给了一段 code 明确告知 in-line view 中给定的 condition 有 multiply observations satisfied the condition, 问 program 运行结果。答案是运行出错没有 结果,因为 in-line view return multiple results. 考到的填空题目(后面论坛机经总结中有详细题目) out union corr average of … is 7 %put _Global_ ; HashAlpha 人大经济论坛机经总结 New questions SQL 1. 填空 Data three; set one two; run; ó proc Append base=one data=two;run; ó proc sql; select * from one OUT UNION CORR select * from two;quit;
Image of page 2
2. Merge statement in data procedure ó proc sql; FULL join with coalesce() function 63 题库 q.13 变型 Note: before using merge procedure, we need to sort variable first. In the question, one table is unsorted, so we cannot use merge procedure. 3. in-line view 考了两道题 (i) proc sql; create table forecast as select a.*, b.sales from actual a, _________ where a.dept=b.dept; quit; Answer: (select avg(revenue) as average from Budegt group by 1) b Note, if select is out of the parentheses, then it is wrong. Beside, in-line view cannot use order by statement. e.g. the following code is wrong select( avg(revenue) as average from Budegt group by 1) b (ii) given a failed program, ask the reason of failure. Proc sql; select Jobcode, Salary, (select avg(Salary) from WORK.PILOTS order by Jobcode) as Avg
Image of page 3

Subscribe to view the full document.

from WORK.PILOTS order by ID; quit; Answer: Order By statement cannot be used inside of an in-line view. Warning: There is another choice says that if using in-line view then we cannot use Order By statement.
Image of page 4
Image of page 5
  • Fall '14
  • Test, Microsoft SQL Server

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern