We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


Any SAS programmer to help

anshuma asked
Medium Priority
Last Modified: 2010-04-17
I have a set of 50 observations. Once I read them they are read into the data set. The main variable is say TreatmentTime

Apart from that I also want to create a variable tempIndex which is say 1 for observation 1 , 2 for observation 2 and so on. So that I can use tempindex for other calculations. How do I do that

Watch Question

SAS uses the temporary variable _N_ as a counter.  To save this as a permament variable, just assign it.

DATA NewDataSet; SET YourDataSet;
Tempindex = _N_;

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts



I am just getting started with SAS. I hope you will try to help me in future also.

sincere regards

My pleasure.  I like SAS a lot and have been using it for many years.

-- tobydavid
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.