sas - 在 SAS 中创建年龄组变量
问题描述
我需要帮助创建这个年龄组变量。在我的数据中,年龄被测量到小数点后 9 位。我可以决定我刚刚选择的四分位数的类别。但我不断收到这些错误...
“错误 388-185:需要算术运算符。错误 200-322:符号无法识别,将被忽略。”
我已经尝试四舍五入并将 le 更改为 <= 但它仍然给出相同的错误...... :(
data sta310.hw4;
set sta310.gbcshort;
age_cat=.;
if age le 41.950498302 then age_cat = 1;
if age > 41.950498302 and le 49.764538386 then age_cat=2;
if age > 49.764538386 and le 56.696966378 then age_cat=3;
if age > 56.696966378 then age_cat=4;
run;
解决方案
这东西最好使用 proc 格式。您在和算术运算符之后缺少变量名。你也不需要 age_cat = 。在一开始的时候。请在您的算术运算符之后和之前添加您的年龄变量,如下所示
data sta310.hw4;
set sta310.gbcshort;
age_cat=.;
if age le 41.950498302 then age_cat = 1;
if age > 41.950498302 and age le 49.764538386 then age_cat=2;
if age > 49.764538386 and age le 56.696966378 then age_cat=3;
if age > 56.696966378 then age_cat=4;
run;
推荐阅读
- javascript - 有没有办法防止 JS 中的 Date 对象溢出天/月?
- c# - Scaffold-DbContext 失败。System.TypeLoadException:无法在 .NET Core 上加载类型“Microsoft.EntityFrameworkCore.Internal.ProductInfo”
- youtube-livestreaming-api - 找不到直播
- css - 自定义 v-select 下拉位置
- machine-learning - SpaCy-transformers 回归输出
- flutter - 如何使用颤振插件 video_player 播放多个源
- html - 让 div 覆盖整个图像
- php - 无法创建会话客户端对话流
- c - 你需要使用不完整类型的 extern 吗?
- node.js - w3c 验证器不工作 --> SSL 连接尝试失败