BookmarkSubscribeRSS Feed
Fluorite | Level 6

I have a data set where the Columns are labeled Month181, month182 , month183, .............., month1810 , month1811, month1812, month191, month192


I want to be able to select the last 12  months for example i want the cols Month1810 to Month199



Month1810    Month1811  month1812   month191  month192   month193    

1                           0                  0                     0              1               0

0                            1                 0                    0                 1             1

1                            1                 0                   1               1                  0

0                            1                0                   1              1                   1

Diamond | Level 26
keep month1810--month199 /* add other variables you want to keep as well */;

in a SAS data step will get you there.


I point out that this is a very poor arrangement of the data for most purposes, and you'd be much better off (for most purposes) with a long data set rather than a wide data set.

Paige Miller
Super User
If you'd used 1801, 1802, 1803 etc it would have been easier. Is this structure the original structure of the data? If not, if you every have it in a long structure, it's much easier to work with in that structure.
Calcite | Level 5



Why don't you convert your file into Excel and then delete the observations you don't need.


Super User
Most likely because that's a manual solution that doesn't scale when you do it every month and multiple times. It allows the room for errors to be introduced.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 4 in conversation