使用范围系统对 SAS 中的变量进行分类 [英] Categorizing variabels in SAS using a range system

查看:22
本文介绍了使用范围系统对 SAS 中的变量进行分类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同员工工资的数值.我想将范围分成几类.但是我不想要一个新列,我只想将现有的薪水列格式化为这个范围方法:

I have the numeric values of salaries of different employee's. I want to break the ranges up into categories. However I do not want a new column rather, I want to just format the existing salary column into this range method:

至少 20,000 美元但低于 100,000 美元 -

至少 100,000 美元,最高 500,000 美元 - >100,000 美元

At least $20,000 but less than $100,000 -

At least $100,000 and up to $500,000 - >$100,000

缺少 - 缺少薪水

任何其他值 - 工资无效

Any other value - Invalid salary

我在性别方面做过类似的事情.我只想使用 proc print 和 format 命令来显示薪水和性别.

I've done something similar with gender. I just want to use the proc print and format command to show salary and gender.

DATA Work.nonsales2;
SET Work.nonsales;
RUN;

PROC FORMAT; 
VALUE $Gender 
'M'='Male' 
'F'='Female' 
'O'='Other'  
other='Invalid Code';

PROC FORMAT; 
VALUE salrange 
'At least $20,000 but less than $100,000    '=<$100,000 
 other='Invalid Code';


PROC PRINT;
title 'Salary and Gender';
title2 'for Non-Sales Employees';
format gender $gender.;
RUN;

推荐答案

Proc 格式是正确的方法,你需要一个数字格式:

Proc Format is the correct method and you need a numeric format:

 proc format;
 value salfmt
 20000 - <100000 = "At least $20,000 but less than $100,000"
 100000 - 500000 = "100,000 +"
 . = 'Missing'
 other = 'Other';

然后在您的印刷品中应用格式,类似于您为性别所做的.

Then in your print apply the format, similar to what you did for gender.

format salary salfmt.;

这应该可以帮助您入门.

This should help get you started.

这篇关于使用范围系统对 SAS 中的变量进行分类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆