Hi,
I'm currently trying to use SAS to get rid of the empty excel rows while also deleting some additional columns that I don't need.
Is there a generic formula I can use to do this? I'm also using the SAS University edition, not sure if that'll change anything too much.
Thanks!
Why not just fix your Excel spreadsheet and then re-import your data?
I have to do this as part of an assignment for my professor so he wants us to use SAS. I would much rather use excel.
IMO a dumb assignment then 😀.
Investigate the DROP statement for deleting extra columns and the WHERE statement for deleting extra rows.
It really is, I'm honestly losing my mind because I don't know how to use SAS.
I'll try to use the DROP function. Quick question a few of my classmates have used this:
options missing = ' ';
data examtwo;
set examtwo;
if missing(cats(of_all_)) then delete;
run;
- BUT this isn't working for me. It just deletes all my data. Not sure if this is also a possible option?
There's a typo in your code - add a space between of and _all_. Without seeing your data not sure it will work though:
options missing = ' ';
data examtwo;
set examtwo;
if missing(cats(of _all_)) then delete;
run;
DROP is a statement not a function:
data want;
drop COLA COLB;
set have;
run;
Depending on the number of variables you need to drop, it could be easier to use the keep statement instead of drop. With the following keep-statement all variables from FirstVar to LastVar are kept, all vars before FirstVar and after LastVar are dropped.
keep FirstVar--LastVar;
Hello,
If they are simply just empty rows and you know the range that you want to remove, try this:
DATA WORK.Want;
SET WORK.Have;
IF _N_ IN (row#:row#) THEN DELETE;
RUN;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.