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.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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