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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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