DATA Step, Macro, Functions and more

need sas loop code

Reply
Contributor Go
Contributor
Posts: 72

need sas loop code

how can i achieve below ? 

need sascode (loop code) to extract several data sets each having data of each city from a large dataset  which has a column/header as CITY ???

 

Super User
Posts: 13,018

Re: need sas loop code

What is the name of your source data set?

What is to be the name of the resulting data set?

How do we know which information (records to extract, records with values of ??? for City)?

What does the result look like?

What will you do with the multiple data sets after extraction?

 

 

Many times there may be absolutely no need to extract data at all and usually extracting into multiple data sets based on the value of one or more variables may cause more work than a different approach.

SAS has a feature called "By Group processing" which means you can make a separate report by the value of one or more variables such as BY CITY from a large data set. You can restrict the data to a reduced set of records with a WHERE statement such as: Where city in ('New York' 'Chicago' 'Memphis') to process data only from those cities.

 

BTW be careful with variables like City as many cities have more than one when state (or province or other sub-region) is considered. Springfield for example is in 24 states or protectorates.

Super User
Super User
Posts: 7,847

Re: need sas loop code

I seem to remember that there are three Springfields in Pennsylvania.

Ask a Question
Discussion stats
  • 2 replies
  • 117 views
  • 2 likes
  • 3 in conversation