- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Quarter
202009
202003
202003
202006
Is there a way to convert this to a date? Ideally something like ddmmmyy
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Are these numeric values? Are these formatted as yymmn6.? Are they character values?
Depending on your answers above, the method to convert to dates changes.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
excel is 202009 (example). Thanks ##- Please type your reply above this
line. No attachments. -##
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
But I don't care how it displays in Excel. Is that how it displays in SAS? Is it numeric or character in SAS?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @ywon111 , @PaigeMiller is asking for the metadata/descriptor info or in other words properties of your sas dataset that was created by importing the contents of the excel file.
To view the descriptor portion, you would need to run
proc contents data=your_sasdataset;
run
The output of proc contents would contain whether your quarter variable is numeric or char and other info. Please provide that info and then based upon which the SAS community would recommend your much needed solution. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ywon111 wrote:
Have a dataset with a quarter variable like below:
Quarter
202009
202003
202003
202006
Is there a way to convert this to a date? Ideally something like ddmmmyy
Thanks
Yes there is a way. Assuming the value you show is actually YYYYMM (not quarter but month). However the approach varies depending on 1) whether the value after you brought it into SAS is character or numeric and 2) which particular date, which must include a day of the month, you want. The simplest SAS tools would assume that you want to create the first date of the calendar quarter such as 01/09/2020. If you expect something else from 202009 then you need to specify it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It's formatted as numeric in SAS.
From proc contents: Format: BEST12.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Since the variable shows months, not quarters, you can convert it with this:
quarter = input(put(quarter,6.),yymmn6.);
format quarter yymmdd10.;