Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do this in SAS?

Status
Not open for further replies.

loveitlive

Technical User
Aug 8, 2007
1
US
Hi, everybody, could you help me with the following question: I am loading data from Excel to SAS. In Excel,some of the data is like:

Min Max Rate
300 350 $1200

300-350 is a range where they all have the same rate of $1200, so I want to create a dataset in SAS that is like the following:
code Rate
300 $1200
301 $1200
302 $1200
...
350 $1200.

How can I do this? Thank you so much for your help.
 
While you can do something like this using a DO loop I wonder why you want the data in sas that way. Perhaps you can elabarate and tell us what your goal is. Do you want to run statistics, get avarages etc. Cause if that's all you want you can leave the data the way it's found in Excel and get accurate results without expanding the data.

Well I can't be the one to decide how you should code here is how you would do it your way.
First import your data using Proc import. Then in datastep expand your data like this:

Code:
data expandeddata;
  set your_data;
  do i=min to max;
   code = i;
   output;
  end;
run;

Hope this helps you.
Klaz
 
Interesting. My guess would be that you want to then join this information on to some other dataset to put the correct rate onto the records in it.

If that's the case, you'd be better off using PROC FORMAT with the CNTLIN= option, to use the data you have to create a ranged format, then apply the format to the data that you want to update (assuming I've guessed correctly).

Check out this example here:-


Chris
Business Analyst, Code Monkey, Data Wrangler.
SAS Guru.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top