Hi there,
I wanted to extract the Month and Year from the date and soft them by MonthYear.
After running the following code I see that MonthYear in sas dataset (want) is also $7. format. When I export the dataset to excel (os that I can do some manipulation in excel) I see that MonthYear is not in date format. Can someone please help.
data want;
set have;
MonthYear=put(Date,monyy7.);
run;
You haven't actually asked a question. It seems like your sample code would get you the month and year.
What is the problem?
Now that you have added a paragraph to the original message, I withdraw my questions.
Why not make life easy and just create two variables:
data want;
set have;
y = year(date);
m = month(date);
run;
They will pass to Excel easily, and can easily be sorted in any order you need.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.