本文介绍了SAS 中的串联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我完成我的任务.我有问题:

Help my with my task, please. I have a problem:

Name Age Height Eyes
Dan  25   174   Blue
Dan  54   165   Black
Jane 33   160   Blue
Kate 19   170   Green

我需要:

Name Characteristic
Dan     25
        174
        Blue
Dan     54
        165
        Black
Jane    33
        160
        Blue
Kate    19
        170
        Green

我尝试通过连接来实现:

I tryed to do it with concatenation:

Characteristic=Age||Height||Eyes

但它从特征中形成一行,而不是一列:

But it makes one line from characteristics, but not a column:

Name   Characteristic
Dan    25 174 Blue
Dan    54 165 Black
Jane   33160 Blue
Kate   19 170Green

我知道,我需要使用 split 来解决这个问题.帮帮我,请给一些建议

I knew, I need use split to solve this moment. Help me, please with some advice

推荐答案

您需要将其全部转换为字符以使其成为一个字段.您也可以使用 data _null_ 步骤来创建报告.

You need to convert it all to character to have it one field. You may also be able to use a data _null_ step to create your report.

这里介绍了如何将数据转换到一个字段,然后您可以在该字段上使用 proc 报告.这是一个转置问题,而不是串联问题.

Here's how you could transpose your data to one field that you could then use proc report on. This is a transpose problem, not concatenation.

data have;
input Name $ Age Height Eyes $;
cards;
Dan  25   174   Blue
Dan  54   165   Black
Jane 33   160   Blue
Kate 19   170   Green
;
run;

data want;
set have;
characteristic = put(age, 8. -l); output;
characteristic = put(height, 8. -l); output;
characteristic = Eyes; output;
drop age height eyes;
run;

如果您要创建文本文件或不同的输出,这可能就是您想要的:

If you were creating a text file or a different output this may be what you want:

data _null_;
set have;
file '/folders/myfolders/want.txt' dlm=" ";
put Name "09"x Age;
put "09"x Height;
put "09"x Eyes;
run;

希望有帮助!

这篇关于SAS 中的串联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 20:00