Lab
新的!:用proc sql 创建一个table
Proc sql;
create table __as
Select__. From 1point 3acres bbs
From__
Where__. From 1point 3acres bbs
Group By__
Having__
Order by__;
Quit;
以下皆原题. ----
在proc SQL里创立一个table,table里读取某个文件所有的变量,但只显示另外一个文件里NAME存在的观察。 ..
Proc sql;
Create table sql01 as
Select *
From cert.input01
Where name in (select name from cert.input02). 1point 3 acres
Quit; . Waral dи,
写一个array,把一个dataset的所有的missing value变成0-. Waral dи,
Data act02;
Set cert.input02;
Array vars(*) trip1-trip25;
do i=1 to 25 ; 原jj用的Do over vars但是我考试用了报错,所以我是先用 proc print查看了需要操作的变量然后直接用的)
If vars(i)=. Then vars(i)=0;
End; . From 1point 3acres bbsDrop i;. ----
Run;
. Waral dи,
在PROC SQL里面创建一个新的Variable,case expression:
proc sql;
Create table sql01 as
Select month, date, case
When a<1000 then ‘low’
When a<2400 then ‘middle’.google и
Else ‘high’
End as new_variable
From cert.input01;. Χ
Quit;
proc fcmp IN to CM, 建好function后options cmplib=work.functions,然后建个新data里面有个新列newheight=IN to CM(height)cm=2.45IN. 1point 3acres
Proc fcmp outlib=work.function.dev;
Function INtoCM(inch);
Cm=inch*2.45;.
Return(cm);
Endsub; .google иRun;
Options cmplib=work.function;. 1point 3 acres
Data ACT03;
Set cert.input03;. Χ
NewHeight=INtoCM(height);
Run;
array 把q1-q10的A,B,C,D,E换成1,2,3,4,5存在num1-num10中. .и
data work.result;
SET abcde;
Drop i;
ARRAY CharNum(10) Q1-Q10;.1point3acres
ARRAY numnum(10) num1-num10;
DO i=1 to 10;
If qq(i)=’A’ then numnum(i)=1;
Else If qq(i)=’B’ then numnum(i)=2;
Else If qq(i)=’C’ then numnum(i)=3;
Else If qq(i)=’D’ then numnum(i)=4;
Else If qq(i)=’E’ then numnum(i)=5;
End;
Run;