
617 P.2d 1317 (1980)
94 N.M. 802
Lawrence LUNG et al., Plaintiffs-Appellants,
v.
Fred L. O'CHESKY et al., Defendants-Appellees.
No. 12780.
Supreme Court of New Mexico.
October 8, 1980.
*1318 Calhoun, Morton, Deason & Preslar, Fred J. Morton, Charles A. Deason, Jr., El Paso, Tex., John P. Otto, Phoenix, Ariz., for plaintiffs-appellants.
Jeff Bingaman, Atty. Gen., Sarah Bennett, Asst. Atty. Gen., Santa Fe, for appellees.

OPINION
SOSA, Chief Justice.
This action was begun in the district court of Santa Fe County. Plaintiffs are Texas residents and employees of the federal enclave known as White Sands Missile Range. They brought suit individually and as a class alleging that the New Mexico Income Tax is unconstitutional as applied to them, and seeking declaratory and injunctive relief, as well as a refund of monies already paid. The trial court dismissed the third claim by interlocutory order for failure to exhaust administrative remedies. *1319 The other two claims were tried to the court without a jury, and judgment was entered denying all relief. Plaintiffs appeal this judgment and we affirm.
Four attacks are made on the constitutionality of the New Mexico income tax as applied to these plaintiffs. First, it is contended that the tax fails because these taxpayers do not get enough for their money; there is not a sufficient "fiscal relation" between them and the State of New Mexico. See Wisconsin v. J.C. Penney Co., 311 U.S. 435, 61 S.Ct. 246, 85 L.Ed. 267 (1940). In support of this, plaintiffs present evidence that New Mexico has in fact spent very little money on their behalf. We find such an inquiry necessarily incomplete and unpersuasive. The power to tax does not rest on a measurable economic duty of the State toward its citizens, but on less tangible benefits, on the "fruits of civilization." J.C. Penney Co., at 446, 61 S.Ct. at 250, quoting Compania de Tobacos v. Collector, 275 U.S. 87, 100, 48 S.Ct. 100, 105, 72 L.Ed. 177 (1927) (Holmes, J., dissenting). The opportunity to exercise "intelligence, skill, and labor while employed in the State of New Mexico" has been held to be sufficient benefit to support an income tax. Jackling v. State Tax Commission, 40 N.M. 241, 248, 58 P.2d 1167, 1171 (1936). Under this test, plaintiffs have a sufficient nexus with New Mexico to be taxed.
Plaintiffs' second argument is that they are discriminated against by the New Mexico allocation and apportionment procedure for residents of Texas with New Mexico income. New Mexico only grants plaintiffs a percentage of New Mexico deductions and exemptions according to how much of the total income was earned in this state, relying on the state of residence to allow the corresponding percentage of deductions and exemptions to bring the total deductions to 100% of those allowed. Since Texas has no income tax, this reliance fails, and plaintiffs assert their claim that the loss of some portion of their New Mexico deductions amounts in effect to a tax on their out-of-state income, or to arbitrary discrimination against them as non-residents.
The State argues that the tax is not discriminatory and that non-residents pay income tax at the same rate as residents. It argues further that even if the effect of the New Mexico Income Tax Act is to apportion exemptions and deductions in relation to the amount of total income earned within the state, such a provision is constitutionally permissible. We agree. It is clear that a state may tax income produced in that state by a non-resident. Shaffer v. Carter, 252 U.S. 37, 40 S.Ct. 221, 64 L.Ed. 445 (1920). It is equally clear that a state may not tax the income of a non-resident which is not produced in the state. It follows that a state need only accord deductions and exemptions to non-residents for the portion of their income which is earned from within the state. If the state has no jurisdiction to tax the income from a particular source, there is no reason for it to extend exemptions and deductions to a non-resident based on that income. See Shaffer v. Carter. The reason a state may give a resident full deductions and exemptions even though a portion of his income is earned outside the state is that the state has the power to tax all the income of the resident, wherever earned. Id. We find no discriminatory taxing scheme under these facts.
Plaintiffs' third objection to the application of this tax, that the state cannot tax within a federal enclave such as White Sands Missile Range, is refuted by the express language of the Buck Act, 4 U.S.C. §§ 106-110 (1977). This act provides that:
No person shall be relieved from liability for any income tax levied by any State, or by any duly constituted taxing authority therein, having jurisdiction to levy such a tax, by reason of his residing within a federal area or receiving income from transactions occurring on services performed in such area; and such State or taxing authority shall have full jurisdiction and power to levy and collect such tax in any federal area within such State to the same extent as though such area were not a federal area. *1320 The argument that this Act only permitted taxes in effect the year it was passed, and not any subsequent ones, was rejected by this Court in Burns v. State Bureau of Revenue, Income Tax Div., 79 N.M. 53, 439 P.2d 702 (1968), cert. denied, 393 U.S. 841, 89 S.Ct. 119, 21 L.Ed.2d 111 (1968).
The final attack on the New Mexico tax structure as applied to these plaintiffs concerns a program of grocery and medical rebates given to New Mexico residents. Appellants claim that a refusal to grant them these rebates purely on the grounds of their non-resident status violates the Privileges and Immunities Clause of the United States Constitution. We disagree. A state is not forbidden to make distinctions between residents and non-residents if they are rationally related to a legitimate state interest. Baldwin v. Montana Fish & Game Comm'n., 436 U.S. 371, 98 S.Ct. 1852, 56 L.Ed.2d 354 (1978). As the trial court found, the state interest in this case is to grant relief from gross receipts and property taxes to low-income individuals who actually pay those taxes. The legislature could reasonably believe that non-residents of this state do not actually pay these taxes; a rebate given to them would not afford relief for monies exacted by New Mexico. Therefore, the distinction between residents and non-residents is rationally related to a legitimate state purpose, and can be permitted to stand.
That part of plaintiffs' appeal which assigns error on procedural grounds fails under our decision on the merits. The trial court's error in granting a motion not made by defendants was entirely harmless, as it simply resulted in a second amended complaint. The dismissal of that part of the case which concerns the refund of taxes already paid was also harmless error in view of the final outcome of the case. Since those issues which would have been litigated under the last claim are precisely the same as those which are here affirmed, they are not prejudiced by the loss of a claim for relief.
The judgment is hereby affirmed.
EASLEY and PAYNE, JJ., concur.
