As 2022 draws to a close, it is safe to say Wall Street won't remember this year fondly. Economic problems such as inflation, a persistent pandemic, and geopolitical tensions are some factors contributing to the broader market's poor performance this year. No one can predict when equities will recover, but when they do, it will pay to have skin in the game.

Buying undervalued stocks today could help investors beat the market in the next five years and beyond. Let's look at two biotech stocks that look attractive at current levels: AbbVie (ABBV -0.93%) and Gilead Sciences (GILD -0.25%).

ABBV Chart.

ABBV data by YCharts.

1. AbbVie

AbbVie is one of the largest pharmaceutical companies around. It boasts a solid portfolio of drugs which includes Humira, a blockbuster rheumatoid arthritis medicine that was still the world's best-selling non-coronavirus pharmaceutical product last year.

Like other drugmakers, AbbVie benefits from the fact that doctors do not stop prescribing lifesaving drugs even during challenging economic times, nor do patients stop taking them. The company's financial results have remained afloat despite the marketwide headwinds we have witnessed over the past nine months. 

In the second quarter, AbbVie's revenue increased by a decent 4.5% year over year to $14.6 billion. The company's earnings per share clocked in at $0.51, 21.4% higher than the prior-year period. Among those products leading the way for AbbVie were Skyrizi and Rinvoq, the two immunology drugs tasked with replacing Humira. 

With a U.S. patent cliff fast approaching -- generic competition for Humira should start in the country sometime next year -- AbbVie's newer medicines will have to take up the torch.

During the second quarter, sales of Rinvoq increased by 56.3% year over year to $592 million. Skyrizi's revenue was $1.3 billion, 85.9% higher than the year-ago period. Humira's sales were $5.4 billion, an increase of 5.8% year over year. Both Skyrizi and Rinvoq are still targeting label expansions, and both have a long runway for growth ahead. 

According to CEO Rick Gonzalez, AbbVie will have achieved "some level of stability on the tail of Humira" by the end of 2024. The company's revenue may suffer when generics first enter the market, but it will recover thanks to its immunology lineup and other products, including its Botox franchise.

AbbVie has performed a lot better than the broader market this year. However, the healthcare giant remains reasonably valued. AbbVie's forward price-to-earnings (P/E) ratio is 10.4, compared to the pharmaceutical industry's average of 12.5.

AbbVie is also an excellent dividend stock. The drugmaker currently offers a yield of 3.92%, along with a solid cash payout ratio of 43.5%. As a Dividend King, AbbVie will continue rewarding shareholders will payout increases. That's just one more reason this stock is attractive -- that is, in addition to its reasonable valuation and solid long-term prospects. 

2. Gilead Sciences 

Gilead Sciences hasn't performed as well as AbbVie recently. The company has encountered regulatory headwinds over the past couple of years that have prevented it from launching key products, and it has faced generic competition for some of its HIV medicines. The biotech has been able to keep revenue growing, if ever so slightly, thanks to its COVID-19 therapy Veklury.

However, the coronavirus landscape beyond this year is uncertain. Thankfully, Gilead Sciences isn't dead in the water. It is the leader in the HIV market, with solid market shares for some of its products. For instance, Biktarvy's share of the HIV treatment market in the U.S. jumped by 4% year over year to 44% in the second quarter.

It remains the leading HIV medicine in the country by a mile, as well as the fastest-growing. It's also worth noting that the pandemic led to lower prescriptions and patient starts in the HIV market, and as things pick back up, Gilead Sciences' products in this space will also perform better.

Further, the company isn't done innovating in the HIV space and elsewhere. In August, the company earned marketing approval for Sunlenca in Europe. Sunlenca is an HIV treatment administered only twice a year -- the first of its kind. Regulators in the U.S. initially declined to approve this product due to manufacturing issues.

But Gilead Sciences resubmitted an application after discussions with regulatory agencies, and it looks pretty likely to earn the green light in the country. Gilead Sciences has dozens of other programs in the pipeline, and these will help it strengthen its lineup over the years. The biotech is currently trading for an attractive forward P/E of 9.8.

Also, Gilead Sciences offers a dividend yield of 4.45% and a cash payout ratio of 38.9%, making it an excellent pick for income-oriented investors. Despite the issues it has encountered lately, Gilead Sciences is a solid stock to buy and hold through this year and beyond.