由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - sas macro, proc sql 问题
相关主题
[合集] SAS问题求助-如何把普通变量的值传递给宏变量need help SAS Macro
请教一个SAS Macro的问题请教Macro(SAS)
SAS adv 8 -one problem -help please唉,还得求教前辈
请教 SAS macro function 的问题sas macro 问题
请教一道SAS Adv,killtest 85【包子】求问个简单sas macro问题
how to use first.var in sas macro?SAS question
SAS help needed请教SAS IML调用DATA step数据的问题
Weird SAS macro bugs, 包子重谢!请教一个SAS 数据分配问题
相关话题的讨论汇总
话题: 402话题: 2001话题: sas话题: product1话题: sales
进入Statistics版参与讨论
1 (共1页)
b****u
发帖数: 67
1
问题一
看不出毛病呀, 答案D也不work 呀?
85. Given the SAS data set OURDATA:
OURDATAObsproduct sales
1 OR 1000
2 NE 1200
3 MM 1450
After submitting a SAS program, the following is written to the SAS log:
70 %macro a;
71 data _null_;
72 set ourdata;
73 call symput('product'!!left(_n_), product);
74 run;
75 %if &product1 = OR %then %do;
76 proc means data = ourdata;
77 run;
78 %end;
79 %mend;
80 %a
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
73:66
NOTE: There were 3 observations read from the data set WORK.OURDATA.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is
required. The condition was: &product1=OR
ERROR: The macro A will stop executing.
Which statement replaces the code in line 75 to successfully complete the program?
A.%if &product1 = %bquote(OR) %then %do;
B.%if %bquote(&product1) = OR %then %do;
C.%if %bquote(&product1 = OR) %then %do;
D.%if %bquote(&product1) = %bquote(OR) %then %do;
/*********/
问题二
我机器上run出来是B呀,为什莫答案是C 呢?
谢谢
7. Given the SAS data sets ONE and TWO:
ONETWO
YEARQTRBUDGETYEARQTRSALES
20013 50020014 300
20014 40020012 200
20021 70020021 600
The following SAS program is submitted:
proc sql;
select one.*, sales
from one, two
where one.year = two.year;
quit;
Which report is generated?
A.YEAR QTR BUDGET SALES
TestInside A00-212
2001 4 400 300
2002 1
B.YEAR QTR BUDGET SALES
2001 3 500 300
2001 4 400 200
2002 1 700 600
C.YEAR QTR BUDGET SALES
2001 3 500 300
2001 3 500 200
2001 4 400 300
2001 4 400 200
2002 1 700 600
D.YEAR QTR BUDGET SALES
2001 3 500 300
2001 4 400 300
2002 1 700 300
2001 3 500 200
2001 4 400 200
2002 1 700 200
2001 3 500 600
2001 4 400 600
2002 1 700 600
Answer: C
d******9
发帖数: 404
2
Question 2:
C is correct. 5 obs because SQL built a Cartesian product.
See the below SAS output.
data one;
input year $ qtr budget;
cards;
2001 3 500
2001 4 400
2002 1 700
;
run;
data two;
input year $ qtr sales;
cards;
2001 4 300
2001 2 200
2002 1 600
;
run;
proc sql;
select one.*, sales
from one, two
where one.year = two.year;
quit;
======================
The SAS System 23:32 Wednesday, April 1, 2009 1
year qtr budget sales
ƒƒƒƒƒƒƒ&#
402;ƒƒƒƒƒƒƒƒƒƒƒƒ
ƒƒƒƒƒƒƒƒƒƒƒƒ&#
402;ƒƒƒƒƒ
2001 3 500 300
2001 3 500 200
2001 4 400 300
2001 4 400 200
2002 1 700 600
d******9
发帖数: 404
3
Question 1:
Not sure.I suggest u go to SAS web to learn about the %BQUOTE function.
1 (共1页)
进入Statistics版参与讨论
相关主题
请教一个SAS 数据分配问题请教一道SAS Adv,killtest 85
[Help] Dividing a SAS data sethow to use first.var in sas macro?
%do questionsSAS help needed
SAS help : how to macro odsWeird SAS macro bugs, 包子重谢!
[合集] SAS问题求助-如何把普通变量的值传递给宏变量need help SAS Macro
请教一个SAS Macro的问题请教Macro(SAS)
SAS adv 8 -one problem -help please唉,还得求教前辈
请教 SAS macro function 的问题sas macro 问题
相关话题的讨论汇总
话题: 402话题: 2001话题: sas话题: product1话题: sales