BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aarony
Obsidian | Level 7

i have a column called  annualreportdate

that column has observations such as dec2012, dec 2010, dec 2011, current

1.)  how do i delete all the rows with current?

1.1) instead of deleting, how do i replace those with 2013?

2) i also want to remove all the dec from dec 2012, dec 2010....and so on.

plz help!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

One way to remove creating a new data set:

data want;

     set have;

     if annualreportdate="current" then delete;/* have to assume the variable is character if the value is actually "current"*/

/* you also may have to address case if sometimes it is current, Current, or CURRENT, so better would be*/

     if upcase(annualreportdate) = "CURRENT" then delete;

run;

To modify a value:

     if upcase(annualreportdate) = "CURRENT" then <do something>;

could be

     then annualreportdate='2013';

or

     then annualreportdate=tranwrd(annualreportdate,'dec','');

View solution in original post

1 REPLY 1
ballardw
Super User

One way to remove creating a new data set:

data want;

     set have;

     if annualreportdate="current" then delete;/* have to assume the variable is character if the value is actually "current"*/

/* you also may have to address case if sometimes it is current, Current, or CURRENT, so better would be*/

     if upcase(annualreportdate) = "CURRENT" then delete;

run;

To modify a value:

     if upcase(annualreportdate) = "CURRENT" then <do something>;

could be

     then annualreportdate='2013';

or

     then annualreportdate=tranwrd(annualreportdate,'dec','');

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 1445 views
  • 0 likes
  • 2 in conversation