American Management Systems Inc., an Arlington computer systems and services firm, yesterday reported a steep loss for the fourth quarter and all of 1981--largely related to a computer time-sharing business AMS said it sold to Martin Marietta Corp. and lower than expected revenues from other computer and consulting lines.

Bethesda-based Martin Marietta acquired time-sharing operations that provide services on International Business Machines Corp. computers to federal government and commercial customers, mostly in the Washington area. In 1981, revenues from this business were about $5.6 million, or 7 1/2 percent of AMS overall revenues and about 22 percent of AMS computer services revenues.

AMS, which said it will retain the remainder of its computer services segment, listed a net loss for the year of $749,000 compared with profits in 1980 of $2.1 million ($1.40 a share), as revenues rose 12 percent to $65.6 million. In the fourth quarter alone, AMS had a loss of $668,000 compared with profits of $353,000 (20 cents) with revenues up 18 percent to $17.5 million.

Before taxes or investment tax credits, the loss for the recent quarter was $1.2 million compared with earnings of $471,000 a year earlier; in the year, the pretax loss was $2 million compared with pretax profits of $3.7 million.

Of the quarter's loss, $1 million was a provision to cover costs related to the business sold yesterday.