SAS笔记

Reading data into SAS

  1. Manual data entry with data step
data example1;
	input subject age sex $ totchol bmi cigpday cvd $;
	datalines;
1 39 M 195 26.97 0 Yes
2 46 F 250 28.73 0 No
3 48 M 245 25.34 20 .
4 61 F  225 28.58 30 Yes
;
run;
  1. infile statement with data step (can read any delimited text file)
data subset1;
	infile "E:\SAS_video_1_2\framingham_subset.csv" delimiter="," firstobs=2;
	/* add a colon modifier before the data format. The colon prevents read errors and allows SAS to correctly handle missing leading zeros in one digit months and days */
	input RANDID INTAKE : MMDDYY10. TOTCHOL AGE SEX $ SYSBP;
	format INTAKE MMDDYY10.
run;
  1. proc import statement
/* read Excel file */
proc import out=subset2
					datafile= "E:\SAS_video_1_2\framingham_subset.xlsx"
					dbms=XLSX REPLACE;
		/* grab data from the worksheet "subset" in the original Excel file*/
		sheet="subset"
		/* There's a header row in the Excel file and SAS should use it to assign the variable names */
		getnames=Yes;
run;
/* read csv file */
proc import out=subset3
					datafile= "E:\SAS_video_1_2\framingham_subset.csv"
					dbms=CSV REPLACE;
		getnames=Yes;
run;
  1. import wizard
/* generate proc import code for reading*/

SAS procedures for viewing data

  1. Summaries of properties of SAS data file proc contents
/* order=varnum: requests variable number ordering instead of alphabetical ordering in proc contents */
proc contents data=example1 order=varnum;
run;
  1. View actual file proc print
/* print data */
proc print data=example1 order=varnum;
run;
/* print subset of observations and variables */
proc print data=example1 order=varnum (obs=5);
	/* don't need to add dollar sign here */
	var subject sex cvd;
run;

How to do statistical tests in sas:
Wilcoxon Rank sum: https://www.stat.purdue.edu/~tqin/system101/method/method_wilcoxon_rank_sum_sas.htm
Kruskal Wallis:
https://www.stat.purdue.edu/~tqin/system101/method/method_kruskal_wallis_sas.htm
One-way ANOVA:
https://www.stat.purdue.edu/~tqin/system101/method/method_one_way_ANOVA_sas.htm
t-test:
https://www.stat.purdue.edu/~tqin/system101/method/method_two_t_sas.htm

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值