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