An analytical method to calculate invariants is developed, based on the theory of complete systems of simultaneous linear first order partial differential equations. The application of this algorithm to the general case, in which the invariants are not polynomials is included. For the case of Lie algebras with one invariant the procedure of finding the invariant can be computerized. As an example of this procedure, the algorithm is applied in the calculation of the invariants of the group SA(n,R). The explicit construction of its invariants for n=2,3,4 is given. A theorem determining the order of a polynomial invariant of a Lie group is proven allowing us to show that the invariant of SA(n,R) is a homogeneous polynomial of order 1/2n(n+1) in the generators. From this fact an immediate consequence is that the order in the generators of translations is n. The method is also applied in the calculation of invariants of the dimension six solvable Lie algebras, and dimension seven nilpotent.