BookmarkSubscribeRSS Feed
Go
Quartz | Level 8 Go
Quartz | Level 8

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 ???

 

2 REPLIES 2
ballardw
Super User

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.

Tom
Super User Tom
Super User

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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 832 views
  • 2 likes
  • 3 in conversation