简体   繁体   English

Sas日期格式为yymmn6。 在Excel中无法识别。 最简单的出路是什么?

[英]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.

相关问题 在 Excel VBA 中列出打开的窗口的最简单方法是什么? - What's the easiest way to list out the open windows in Excel VBA? 自动执行Excel任务的最简单方法是什么 - What is the easiest way to automate Excel tasks 在Excel中组成此多项式表达式的最简单方法是什么? - What is the easiest way of composing this polynomial expressions in Excel? 当您在Excel中有很多要绑定的字段时,添加绑定和获取绑定的最佳方法是什么。 Office.js - What is the best way to add bindings and get bindings when you have lots of fields to bind in Excel. Office.js 使用C#创建Excel表的最简单方法是什么? - What's the easiest way to create an Excel table with C#? Excel-计算随时间变化的发病率和患病率的最简单方法是什么? - Excel - What is the easiest way to calculate incidence plus prevalence over time? 自动将宏添加到一组Excel文件的最简单方法是什么 - What is the easiest way to add Macro automatically to a set of Excel Files 使用 Ruby 将 CSV 导出到 Excel 的最简单方法是什么? - What's the easiest way to export a CSV to Excel with Ruby? Excel。 1 个特定列的特殊数字分隔符格式,整个文档没有 - Excel. Special number separator format for 1 specific column, no for the entire document 什么是Excel日期格式以这种特定格式保留日期? - What is the Excel Date Format to retain dates in this specific format?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM