BookmarkSubscribeRSS Feed
Prabhat_kumar
Calcite | Level 5

Hi All,

I am trying to delete the last 3 row where last row "label=B_Contingencies" (highlighted in image).

I tried rownum and partition but seems like sas doesn't support it.need to remove last 3 rowneed to remove last 3 row

 

 

6 REPLIES 6
PeterClemmensen
Tourmaline | Level 20

Show us your code please.

Prabhat_kumar
Calcite | Level 5

This was throwing error as "Syntax expecting one of the following: !,!!, &, *, **, +,-,/,* <,>,<>,="

 

rownumber_partitiion.png

 

andreas_lds
Jade | Level 19

And what do you expect as result?

Prabhat_kumar
Calcite | Level 5

The expected result.expected_result.png

 

andreas_lds
Jade | Level 19

Something like this should  work. Code is untested:

data want;
   _p = 0;
   
   do _n_ = 1 by 1 until(done);
      set work.have end=done;
      if label = 'INSERT_TEXT' then _p = _n_;
   end;

   do _n_ = 1 by 1 until(_p - 1 = _n_);
      set work.have;
      output;
   end;
   
   drop _p;
run;
FloydNevseta
Pyrite | Level 9

Assuming that 'end' provides some meaningful order, then you can try this.

* sort by label and end to group by label;
proc sort data=iqfmt;
by label end;
run;

* then sort by label removing duplicate labels;
proc sort data=iqfmt nodupkey;
by label;
run;

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!

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.

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