Easiest way of deleting line based on row number

Accepted Solution Solved
Reply
Contributor
Posts: 20
Accepted Solution

Easiest way of deleting line based on row number

[ Edited ]

Hi, Im using SAS University Studio 3.4, after 10 years of not using it. 

 

The snippets Filter doesnt allow to delete or filter out data line base on the sas created obs#  

 

I wish to use a simple data net set old if then delete statement but using the OBS# as the criteria 

 

Can somoene pls give me the code I need for that? 

 

THANKS! 


Accepted Solutions
Solution
‎03-24-2016 08:51 AM
Super User
Posts: 19,851

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)


All Replies
Occasional Contributor
Posts: 10

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)

I believe you could do something like this to delete observation #1. _n_ is an automatically generated variable in data steps that's dropped from the output.

 

data newtable;

  set oldtable;

  if _n_ ne 1;

run;

Contributor
Posts: 20

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)

Posted in reply to NScheperle
ill try that thanks - what “ne” stands for exactly pls?

Solution
‎03-24-2016 08:51 AM
Super User
Posts: 19,851

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)

Its a comparison operator - NE - Not Equal

 

They're documented here:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm

Contributor
Posts: 20

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)

It works like a charm
Occasional Contributor
Posts: 10

Re: Easiest way of deleting line based on SAS created OBS # (which isn't a variable)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 378 views
  • 2 likes
  • 3 in conversation