Pharmaceutical companies Moderna (MRNA -0.96%) and Merck (MRK 0.17%) saw their shares rise 19.6% and 1.7%, respectively, on Tuesday after they announced impressive early results from their mRNA cancer vaccine to prevent melanoma, the deadliest form of skin cancer.

Both companies' shares continued to gain on Wednesday. The question is, are those gains warranted, and regardless of the study's results, do the stocks merit a buy?

It's great news for Moderna, but...

First, a little background. This would be a vaccine against cancer, not just against a virus that could cause cancer (like the human papillomavirus and hepatitis B virus vaccines). It's also different from two other "cancer vaccines," Sipuleucel-T and Talimogene laherparepvec, which are used on advanced prostate and melanoma patients, respectively, because this vaccine would be a preventative used on patients who have had prior melanomas excised by surgery and have not yet seen any signs of recurrence. 

To create this vaccine, the companies are using the messenger RNA (mRNA) delivery system that Moderna modified to create its successful COVID-19 vaccine.

The results do seem rather promising. The companies said the combination of Merck's Keytruda, along with the personalized vaccine, mRNA-4157/V940, given to patients who had previous cases of stage III or IV melanoma that had been surgically removed, reduced the likelihood of death by 44%, compared to just administering Keytruda.

The target market is large -- according to the Melanoma Research Foundation, 197,000 new cases of the skin cancer are expected to be diagnosed this year and 7,650 people in the U.S. are expected to die from the disease this year. However, it is important to note that the study hasn't been peer reviewed and the vaccine is a long way from being approved. 

Even with the recent price surge, Moderna trades at just 7 times earnings. While that seems low at first glance, bear in mind that its sales have been declining due to lower COVID-19 vaccine sales.

In the third quarter, the company reported revenue of $3.36 billion, down 32% year over year, and net income of $1.04 billion and earnings per share (EPS) of $2.53, down 69% and 67%, respectively, compared to the same period in 2021. The company has put its COVID-19 proceeds to good use, buying back 20 million shares of stock and spending on 48 programs in development, including several in the late stages.

Moderna still seems to be a great long-term opportunity, but at its current elevated price, it makes sense for investors to wait for it to fall back a bit before investing.

Merck is a different story

Merck's shares barely got a bump from the news, but the pharmaceutical company has a bigger market capitalization than Moderna and its shares were already up more than 44% this year.

Though it trades at roughly 19 times earnings, Merck still seems to be a decent buy now. The company bowed out early from a COVID-19 vaccine, so its comparative sales are stronger than Moderna's.

In the third quarter, Merck reported revenue of $14.96 billion, up 14% year over year, including $15.5 billion from oncology drug Keytruda, which saw sales rise 20% compared to the same period last year. Merck's net income was listed as $3.24 billion, or $1.28 in EPS, down 29% in both cases compared to the third quarter of 2021.

A bigger concern with Merck is that Keytruda, even though it is continuing to add indications, will hit a patent cliff in the U.S. beginning in 2028. That's still a long way off, but the company will need to spend on research and development to replace the blockbuster's sales. 

It already has another potential blockbuster in pulmonary arterial hypertension (PAH) drug Sotatercept, which it obtained in its $11.5 billion buyout of Acceleron Pharma last year. Sotatercept did well in its Stellar phase 3 trial as an add-on to background therapy for the treatment of adults with PAH. If approved, the drug could launch in 2023. 

There are plenty of other reasons why Merck's stock is on solid long-term ground. It has a huge pipeline, with 30 phase 3 programs and 82 phase 2 programs, and that doesn't include potential sales from the melanoma cancer vaccine it is developing with Moderna. The company said it expects more than 80 approvals by 2028, some of which could pay off in a big way. One of the other promising drugs is Nemtabrutinib, a Bruton's tyrosine kinase (BTK) inhibitor being examined to treat blood cancer and solid tumor cancers.

It's easier for long-term investors to be patient with Merck as it has a dividend that has a 2.63% yield. It just raised the dividend by 5% to $0.73 per quarterly share, the 12th consecutive year Merck has boosted its dividend.