我正在使用锻炼应用程序的.csv导出。它记录日期,时间,运动,代表,体重和评论。像许多.csv文件一样,它有点混乱。
例子:
Date,Time,Exercise,# of Reps,Weight,Comments12/23/2014,14:52,Hip Abduction,30,180,12/23/2014,14:52,Hip Abduction,30,180,12/23/2014,14:51,Inverse Bench,15,95,12/23/2014,14:51,Abb Twist,30,100,12/23/2014,14:51,Pull-Ups,5,170,12/23/2014,14:27,Squat,15,135,12/23/2014,14:27,Squat,15,13512/23/2014,14:27,Squat,15,13512/23/2014,14:27,Deadlift,15,135,12/23/2014,14:27,Crunch,30,170,12/23/2014,14:27,Crunch,30,17012/23/2014,14:27,Crunch,30,17012/23/2014,14:26,Bench,15,135,12/23/2014,14:26,Bench,15,13512/23/2014,14:26,Bench,15,135,etc...
我已经能够导入数据,但是将字符数限制为8个。如日期和运动变量所示。
SAS代码:
DATA strength;
infile 'C:\Users\user\Google Drive\strength.csv' DLM = ',' DSD;
input Date $ Time $ Exercise $ Reps Weight Comments;
if date = 'Date' then delete; *removes first obs - the csv header;
RUN;
PROC PRINT data = strength;
title 'Simple Work Out Log Export';
RUN;
SAS输出:
Obs Date Time Exercise Reps Weight Comments
1 12/23/20 14:52 Hip Abdu 30 180 .
2 12/23/20 14:52 Hip Addu 30 180 .
3 12/23/20 14:51 Inverse 15 95 .
4 12/23/20 14:51 Abb Twis 30 100 .
etc...
我没有使用.csv文件的丰富经验,但是我确实尝试使用
input Date $ Time $ Exercise $ 12. ....
但这不起作用,因为不同的练习具有不同的长度名称。
我将如何导入像这样的原始.csv数据文件的完整日期和练习名称?
谢谢!
也可以编写稍微复杂一点的输入语句,而无需使用informat语句即可完成所需的操作:
input date :mmyydd10. time :time. Exercise :$32. reps :8. weight :8.;
然后,您可以应用日期和时间格式:
format date mmddyy10. time time.;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句