BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
matt23
Quartz | Level 8

Hi, I have two excel files but they are not formatted the same way and I want to merge them together. I'd do it manually but there is almost 90,000 observations.

 

One of them goes by day and looks like this:

YearMonthDayWeekdayHoliday
20091141
20091250
20091360
20091400
20091510
20091620
20091730
20091840
20091950

 

the other one goes by hour and looks like this:

YearMonthDayHour
2009110
2009111
2009112
2009113
2009114
2009115
2009116
2009117
2009118
2009119
20091110
20091111
20091112

 

and goes to year 2017

 

Is there a way to combine them into one? Or anything at all ? Maybe in excel ?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Why do you need to "merge" these data sets?

If they are SAS data sets and if you make an actual date value from month, day and year (large economy sized hint: function MDY) then there are SAS functions that will return the day of the week (weekday function)  and whether the date is a standard holiday (holidaytest function).

 

 

View solution in original post

6 REPLIES 6
ballardw
Super User

Why do you need to "merge" these data sets?

If they are SAS data sets and if you make an actual date value from month, day and year (large economy sized hint: function MDY) then there are SAS functions that will return the day of the week (weekday function)  and whether the date is a standard holiday (holidaytest function).

 

 

matt23
Quartz | Level 8

Tha would be great but I have no idea how to do it. I'm new to SAS.

Would you be able to show an example of a code?

jebjur
SAS Employee

Can you show an example of what the final merged data set would look like?

matt23
Quartz | Level 8

Something like this:

YearMonthDayHourWeekdayHolidayVar1Var2Var3
20091311930123122412
200913120303453452423
20091312130243455424
200913122303453454325
200913123304353456525
2009210413453454426
20092115143533544328
matt23
Quartz | Level 8
NVM, just did it in excel.
Kurt_Bremser
Super User

Weekdays have a function in SAS, and holidays also. Since most holidays in the Western world are either fixed by date (eg Christmas or Independence Day) or depend on Easter (which can be determined by the holiday() function), it's easy to determine that on the fly during other data step processing.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 915 views
  • 0 likes
  • 4 in conversation