BookmarkSubscribeRSS Feed
hk2013
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

4 REPLIES 4
PaigeMiller
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
Reeza
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.
imadjabir
Calcite | Level 5

Hello,

 

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

 

Reeza
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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 1753 views
  • 0 likes
  • 4 in conversation