W.P. Carey (WPC -1.70%) and Clearway Energy (CWEN 0.26%) operate in different industries, but they do have one thing in common right now: They're both going to be added to S&P indexes this week.

The spotlight that change offers is drawing attention to the stocks, sending Clearway up by 12% and shares of W.P. Carey up by 5.4% as of 1:30 p.m. Tuesday.

Two beaten-down stocks get a boost

It has been a difficult year for shareholders of both W.P. Carey and Clearway, as macroeconomic conditions have taken a toll on their businesses. Both were down more than 25% year to date coming into Tuesday's trading session.

W.P. Carey is a real estate investment trust (REIT) with a diversified portfolio that includes industrial, retail, office, and self-storage assets. But REITs have been hit hard by rising interest rates and concerns about the long-term demand for office space. Carey is also in the process of shedding its office assets, but dividend investors are worried that a slimmed-down company will have a more difficult time maintaining its payout at recent levels.

Clearway, meanwhile, is one of the largest producers of renewable energy in the U.S., with a portfolio of wind and solar assets. But higher interest rates make it more challenging to grow that portfolio, and in a world where savings accounts are now paying meaningful interest, more speculative dividend payers like Clearway have fallen out of favor with investors.

On Tuesday, S&P Dow Jones Indices gave those stocks a boost. The service announced that prior to the open on Thursday, W.P. Carey will be added to the S&P MidCap 400 index and Clearway will join the S&P SmallCap 600. When such additions occur, mutual funds and exchange-traded funds that track those indexes need to buy the shares, which provides added demand and can support a stock over time.

Are W.P. Carey and Clearway stocks to buy after their index inclusion?

Index addition pops tend to be short lived, but there is a lot for patient investors to like about W.P. Carey and Clearway over the long term. Both pay impressive dividends, which at their current share prices yield 6.9% and 6.3%, respectively, and both look to have solid growth trajectories.

But their near-term issues will not disappear overnight, and both REITs and renewables could be under pressure well into 2024 if economic conditions continue to evolve as they have been. Investors considering buying in now should focus on the long term, and should recognize that index inclusion will not be enough to shield these stocks from broader macroeconomic trends.