SAS数据导入汇总
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
SAS
SAS DATA Step / Viewtable
1.Internal raw data- Datalines or Cards
2.External Raw data files- Infile + Input ;
SAS DATA Step / PROC IMPORT
1.SAS SAS
data sasuser.saslin;
set "F:\sas1.sas7bdat";
run;
proc contents data=sasuser.saslin;
run;
2.SAS PROC IMPORT /
proc import datafile = "c:\data\hsb2.sav" out= work.hsb2;
run;
proc contents data=hsb2;
run;
SAS SAS recognizes the file type to be imported by file extension.
SAS256
256Infile LRECL=n
List
SAS
List Input
1
2
38
4
INPUT Name $ Age Height;
List
SAS Column
Colunm
E
List Column
1
2
3
4
INPUT Name $ 1-10 Age 11-13 Height 14-18;
$informat w.
informat w.d
Datew.
(1)
$CHARw.
$HEXw. 16
$w.
(2)
DATEw. ddmmmyy ddmmmyyyy
DATETIMEw. ddmmmyy hh:mm:ss.ss
DDMMYYw. ddmmyy ddmmyyyy
JULIANw. yyddd yyyyddd Julia
MMDDYYw. mmddyy mmddyyyy
TIMEw. hh:mm:ss.ss
(3)
COMMAw.d $
HEXw. 16
IBw.d
PERCENTw.
w.d
INPUT Name $16. Age 3. +1 Type $1. +1 Date MMDDYY10.
(Score1 Score2 Score3 Score4 Score5) (4.1);
+n n n
@n
INPUT ParkName $ 1-22 State $ Year @40 Acreage COMMA9.;
Breed
My dog Sam Breed: Rottweiler Vet Bills: $478
1SAS Rottweil
Breed DogBreed
2SAS Rottweiler Vet Bill
Breed: DogBreed20
3SAS Rottweiler
Breed:
DogBreed 20
SAS
n
INPUT City $ State $ / NormalHigh NormalLow #3 RecordHigh RecordLow;
Input
@@
SAS
INPUT City $ State $ NormalRain MeanDaysRain @@;
SAS
INPUT
@
SAS
IF
INPUT
INPUT Type $ @;
INPUT Name $ 9-38 AMTraffic PMTraffic; @ & @@ (1)
(2) @SAS
@@
INFILE
1FIRSTOBS=n : n
2OBS=n n
3INPUT
SAS
INPUT
SAS
MISSOVER
TRUNCOVER
column
TRUNCOVER SAS
DATA
INFILE DLM= DSD
1The DLM= option
Tab
2The DSD option
SAS
IMPORT
IMPORT
1
2
3
4SAS
5
6
-set;
SAS
DLM IMPORT DBMS=option
SAS REPLACE
-set DBMS=identifier REPLACE;
IMPORT
IMPORT GETNAMES=NO
IMPORT
DILIMITER=statement
PRO-set
DBMS=DLM REPLACE;
GETNAMES=NO;
-
RUN;
IMPORT PC
-set
DBMS=identifier REPLACE;
SAS
PROC CONTENTS DATA=data-set;
CONTENTS SAS
1
2
1.cars_novname.csv
Acura,MDX,SUV,Asia,All,"$36,945 ","$33,337 ",3.5,6,265,17,23,4451,106,189 Acura,RSX Type S 2dr,Sedan,Asia,Front,"$23,820 ","$21,761
",2,4,200,24,31,2778,101,172
Acura,TSX 4dr,Sedan,Asia,Front,"$26,990 ","$24,647 ",2.4,4,200,22,29,3230,105,183 Acura,TL 4dr,Sedan,Asia,Front,"$33,195 ","$30,299 ",3.2,6,270,20,28,3575,108,186 Acura,3.5 RL 4dr,Sedan,Asia,Front,"$43,755 ","$39,014
",3.5,6,225,18,24,3880,115,197
proc import datafile="cars_novname.csv" out=mydata dbms=csv replace;
getnames=no;
run;