sas程序常用方法解析

本文介绍了SAS编程的基础知识,包括快捷键、数据步和过程步的使用,如数据集操作、文件名定义、数据处理、排序和合并等。还详细讲解了SET、PROC SORT、RETAIN、WHERE、LAG、DROP等关键语句,以及宏的使用和局部变量声明。
摘要由CSDN通过智能技术生成

sas程序

快捷键:
F3 运行
Ctrl+e 清空
Ctrl+o 打开文件快捷键
注释
------;
/
-----------*/

RUN
上下文: [GLOBAL STATEMENT] RUN 语句

Syntax: RUN ;

Executes the previously entered SAS statements.

Although the RUN statement is not required between steps in a SAS program, using it creates
a step boundary and can make the SAS log easier to read.

Arguments:

CANCEL
terminates the current step without executing it. SAS prints a message that indicates that the step was not executed.
CAUTION:
The CANCEL option does not prevent execution of a DATA step that contains a DATALINES or DATALINES4 statement.
CAUTION:
The CANCEL option has no effect when you use the KILL option with PROC DATASETS.

数据步 data

data ngj.test;		#data开头;
.....
.....
run;(quit;)			#执行;

过程步 proc

proc print;			#proc开头;
	title'hello world'
run;(quit;) 		#执行;

文件名
data a;
生成一个a命名的数据集

file print;把本来在日志窗口显示的在输窗口显示

put ‘hello world’ 把引号内内容在日志窗口显示出来
run;

proc print;
run;

proc sort ;data=oranges
run;

libname file_name(自定义文件名称用于存放在sas中,或者使用历史已经定义好的文件名) 地址(文件在电脑中的物理地址)
data file_name.(wenjainming )需要自己定义
例:
libname ngj BASE “F:\WORKSPACE\RISK\niuguangjie”;
data ngj.test;
set apply_20190730;
by apply_no;
run;

一句话,put把数字变成文本,input则反之。

input介绍:
input 后面添加要查看的变量名称 负责生成变量的

	input x1-x5 意思是从x1到x5 [x1 x2 x3 x4 x5]
		x6 $ :意思是x6为字符串形式的变量
		date yymmdd15.  :意思是date为日期形式的变量 占15位
		x7 = 'o' :表示字符串
		x8 = 'i am a student' :表示字符串



	cards:
		后面接数据va
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值