More young Americans than ever are getting the message that it is important to put themselves on a career path involving science, technology, engineering or math, also known as STEM.

That’s good news for our country. After all, the White House Office of Science and Technology Policy forecasts the United States will need about one million more people with STEM educations during the next decade.

But there is bad news as well. A desire to enter STEM-related fields just isn’t enough.

These disciplines suffer from massive attrition. Fewer than four out of 10 students who plan to get a degree in a STEM major will actually get one. Some fail to graduate and others change majors, losing interest in whatever drew them to the subject in the first place.

We shouldn’t be surprised that this happens, given the way many science topics are taught. Imagine learning to play basketball, and the coach decides the best way to learn is by reading about famous basketball players and their game-winning shots, or by watching videos of basketball games. This wouldn’t help much in learning the game.

Instinctively, we know that learning to do something involves actually doing it. Yet, much of the way students are expected to learn science is by reading about discoveries that have already been made and watching demonstrations of phenomena that are well understood.

We need to change how we educate students. We need more of it to be real science.

We recently conducted a study that looked at the Freshman Research Initiative in The University of Texas at Austin’s College of Natural Science, which aims to give students a more authentic science experience in a series of three courses — doing real research and making real discoveries during their first year on campus.

The courses’ long-term effects for students were positive. We compared students who had participated in the initiative with students who had entered the college at the same time and whose backgrounds and demographics were otherwise similar but who did not participate in the three-course program.

The students who participated in doing real science were significantly more likely to graduate from college and complete a STEM degree than their counterparts. The effect was the same for all students, regardless of their gender, race, or ethnicity or whether their parents attended college.

Because diversifying the STEM workforce represents another challenge for our country, the effect across population groups is especially good news. Although the dropout problem for all students in science is sizable, it’s more pronounced for students of color and those who are the first in their families to go to college.

We won’t meet the nation’s economic needs if we don’t meet them for all potential scientists. Having a more diverse STEM workforce also will help produce more creative, effective and feasible ideas in science and technology than we could expect if only a handful of homogenous groups participate in this growing part of our economy.

In a letter to the president, the Office of Science and Technology Policy noted that increasing retention in STEM disciplines 10 percentage points, from 40 percent to 50 percent, would get the United States three-fourths of the way to its target goal of adding 1 million more STEM-educated Americans to the workforce.

If we are going to do that, it is going to make a change in how we educate these students. We can’t limit students to reading about science or repeating the work of others. We must put real-world research problems to students so that they learn science from being in the game, experiencing discovery firsthand.