[英]Sas dates format-yymmn6. is not recognised in excel. what is the easiest way out?
I wanted to automate a bunch of calculations in SAS for ultimately doing a chart in excel. 我想自动化SAS中的大量计算,以便最终在excel中绘制图表。 In this process, I have dates as the column names . 在此过程中,我将日期作为列名。 So to sort them according to the dates I used this format- yymmn6. 因此,根据我使用此格式yymmn6的日期对它们进行排序。 Format to get eg 201604- year, month so that I can sort by dates(dd was always01) . 格式化以获取例如201604-年,月,以便我可以按日期(dd为always01)进行排序。 And added a prefix C_. 并添加了前缀C_。
C_201406 C_201407 C_201408 C_201409 C_201410 ....
MAX 8 5.681818 4.291845 3.755725 2.281169 ....
…
I arrange everything in this order. 我按此顺序安排一切。 I perform all the calculations ready. 我已经准备好所有计算。 When I paste the data in Excel, I removed the prefix C_. 在Excel中粘贴数据时,删除了前缀C_。 The dates are not recognized correctly. 日期无法正确识别。 For eg-201406 is considered as 6/5/2451. 例如-201406被视为6/5/2451。 For my charts I want it in this format Jun-14. 对于我的图表,我希望它采用14年6月的格式。 I am not sure if it is easy to do the change in excel or change originally in SAS and also arrange in an order. 我不确定在Excel中进行更改或在SAS中进行原始更改是否容易,并且还可以按顺序排列。 I want to know how to do this to achieve finally in a format where dates are Jun-14(mmm-YY)? 我想知道如何以日期为Jun-14(mmm-YY)的格式最终实现此目标吗?
Here are two repair routines. 这是两个维修程序。 The first loops through each cell, repairing them as it goes; 第一个循环遍历每个单元,并对其进行修复。 the second repairs the first cell and uses it in a series fill. 第二个修复第一个单元并在系列填充中使用它。
Sub wqewhgwq()
Dim yymmm6 As Range
With Worksheets("sheet5")
With .Range(.Cells(1, "B"), .Cells(1, "B").End(xlToRight))
For Each yymmm6 In .Cells
yymmm6 = DateSerial(Mid(yymmm6.Value2, 3, 4), Right(yymmm6.Value2, 2), 1)
Next yymmm6
.NumberFormat = "mmm-yy"
End With
End With
End Sub
Sub fgsaewrt()
With Worksheets("sheet5")
With .Range(.Cells(1, "B"), .Cells(1, "B").End(xlToRight))
.Cells(1) = DateSerial(Mid(.Cells(1).Value2, 3, 4), Right(.Cells(1).Value2, 2), 1)
.NumberFormat = "mmm-yy"
.DataSeries Rowcol:=xlRows, Type:=xlChronological, Date:=xlMonth, Step:=1
End With
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.