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.
But I don't care how it displays in Excel. Is that how it displays in SAS? Is it numeric or character in SAS?
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!
@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.
It's formatted as numeric in SAS.
From proc contents: Format: BEST12.
Since the variable shows months, not quarters, you can convert it with this:
quarter = input(put(quarter,6.),yymmn6.);
format quarter yymmdd10.;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.