问题描述
我有一个数据文件,我试图将其导入到 SAS 中,如下所示:
I have a data file that I am trying to import into SAS that looks something like the below:
WCM2B W C M 2 B M.B 2 18.4 12.3 g
WCM2B W C M 2 B M.B 2 19.2 12.3 g
WCM2B W C M 2 B S.P 2 19.5 DQ ('')
WCM2B W C M 2 B Z.G 2 17.7 10.7 g
WCM2B W C M 2 B Z.G 2 18.4 10.7 g
WCM2B W C M 2 B Z.G 2 17.6 10.8 g
WCM2B W C M 2 B Z.G 2 20.1 12.1 g
这些列中的每一列都有标题,其中一些列出了分类变量,而另一些则没有.
There are headings for each of these columns, some of which list categorical variables some of which do not.
我的问题:
1) 确保这样的文本文件的正确代码是什么,如上所示,由空格分隔,并在 SAS 中正确格式化了 ~36 行和 11 列数据?然后如何对这些数据执行操作,使其出现在输出窗口中?即使是对某些选定的 infile 执行的最基本的程序也可以.理想情况下,如果有人感觉非常慷慨,我会尝试了解如何进行回归分析,包括分析残差和标准统计数据.
1) What is the proper code for ensuring a text file like this, delimited by spaces as shown above and with ~36 rows and 11 columns of data is properly formatted in SAS? How can I then perform operations on this data so that it comes up in the output window? Even the most basic procedure to do on some chosen infile would do. Ideally, if someone is feeling very generous I am trying to get an understanding of how to do regression analysis including analyzing residuals and standard statistics.
2) 我是否需要将分类变量更改为二进制才能正确分析数据?
2) Do I need to change categorical variables into binary for it to properly analyze the data?
3) 我遗漏的这些数据是否还有其他问题可能会导致其无法工作?
3) Are there any other issues with this data I'm missing that might make prevent it from working?
非常感谢您抽出宝贵时间.
Thank you very much for your time.
推荐答案
如果你有一个制表符分隔的数据文件,你可以考虑至少在最初使用 PROC IMPORT.
If you have a tab delimited data file, you could consider using PROC IMPORT at least initially.
proc import file="//wherever/myfile.txt" out=mydataset dbms=tab replace;
run;
这将生成一个数据集.它还将有用地将输入代码放入日志中.您可以将它从日志复制到您的程序编辑器中,然后在导入过程做出错误决定时进行修改(例如,它可能决定带有DQ"的列应该是一个字符变量).您可以将其调整为数字,然后重新运行粘贴的代码.
That will generate a dataset. It will also, usefully, put the input code into the log. You can copy it from the log into your program editor and then make modifications if the import procedure makes poor decisions (for example, it might decide the column with "DQ" should be a character variable). You can adjust that to numeric, and rerun the pasted code.
现在您可以对该数据集做任何您想做的事情.你可以做这样的事情
Now you can do whatever you want to that dataset. You can do things like
proc freq data=mydataset;
run;
您的其余问题实际上是一般的研究问题,如果不了解您的分析并有大量时间来写答案,就无法轻松回答:) 我建议您在线阅读有关数据分析的内容;这些并不是 SAS 特有的问题,而是一般的研究指南,并且有很多关于这些主题的论文.
The rest of your questions are really general research questions that can't be easily answered without both knowing your analysis and having a lot of time to write answers :) I would recommend doing some reading online on data analysis; these aren't really issues specific to SAS, but are general research guidelines, and there are lots of papers out there on the topics.
这篇关于将数据文件读入 SAS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!