简体   繁体   English

使用 PROC SCORE 更改数据集中的值,使用 SAS

[英]Changing the value in data set using PROC SCORE using SAS

I'm New to SAS Please can one help me how to change the value of data set using PROC SCORE.我是 SAS 的新手请帮助我如何使用 PROC SCORE 更改数据集的值。 I have two data set as shown below image how to append the label value from data set 2 to set 1.我有两个数据集,如下图所示,如何将 append 的 label 值从数据集 2 转换为集 1。

If gender is 1 We should append the value as M from the set 2如果性别是 1 我们应该 append 值作为 M 从集合 2

数据集图像

SAS uses formats as the way to display values in human friendly ways. SAS 使用格式作为以人性化方式显示值的方式。 Looks like you want to convert your second table into a format definition so that you can attach that format to the GENDER variable in your first dataset.看起来您想将第二个表转换为格式定义,以便您可以将该格式附加到第一个数据集中的 GENDER 变量。

From the description it sounds like you want to generate a custom format like this:从描述中听起来您想要生成这样的自定义格式:

 proc format ;
   value gender 1='M' 0='F' other='O' ;
 run;

You could then use a FORMAT statement, inside your Proc SCORE step, to associate the custom format to your GENDER variable.然后,您可以在Proc SCORE步骤中使用 FORMAT 语句将自定义格式与您的GENDER变量相关联。

 format gender gender. ;

It is possible to build a format from a dataset, but you have not described any way to match the values of 0 and 1 in the first dataset to the values M or F in the second dataset.可以从数据集构建格式,但您没有描述将第一个数据集中的 0 和 1 的值与第二个数据集中的值 M 或 F 匹配的任何方法。 What was the logic for deciding that 1 should be mapped to M?决定 1 应该映射到 M 的逻辑是什么? Is it because M is first in the table?是因为 M 在表中排在第一位吗? Is it because F comes before M in the alphabet and 0 comes before 1 in numeric ordering?是因为 F 在字母表中排在 M 之前,而 0 在数字排序中排在 1 之前?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM