是的,您可以使用SAS进行您可能想到的任何“数据清理” . SAS DATA步骤语言充满了这样的功能,但没有灵丹妙药;你需要自己编写代码 .
csv 文件只是一个纯文本文件(与 xls 文件非常不同) . 通常, csv 文件中的第一行包含列名称,数据以第二行开头 . 如果使用 PROC IMPORT ,SAS将使用第一行构造变量名称,并尝试通过扫描文件的前几行来确定数据类型 . 例如:
proc import datafile='c:\temp\somefile.csv'
out=SASdata
dbms=csv replace;
run;
或者,您可以使用数据步骤读取文件 . 这将要求您事先知道文件布局 . 例如:
data SASdata;
infile 'c:\temp\somefile.csv' dsd firstobs=2 lrecl=32767 truncover;
informat A $50.; /* A character variable with max length 50 */
informat B yymmdd10.; /* A date presented like 2012-08-25 */
informat C dollar12.; /* A number containing dollar sign, commas, or decimals */
input A B C; /* The order of the variables in the file */
if B = . then B = today(); /* A possible data cleaning statement */
run;<