I have a variable that looks like:
12341234
.
.
.
12341234123
.
.
.
123412341234
.
.
.
12314123124
I want to keep only the rows with values, i.e. remove the rows without values. How do I do that only for this variable, without changing the other variables in the dataset?
Hi @adrfinance,
Is the variable type numeric or character?
And are you happy to lose the data for the other variables in the same rows where this variable has no value?
Regards,
Amir.
If it is numeric and you are happy to lose the values of the other variables where your variable is missing then you could try the following:
data have;
infile datalines dsd;
input
seq_id : $8.
my_var : 8.
;
datalines;
1,12341234
2,.
3,.
4,.
5,12341234123
6,.
7,.
8,.
9,123412341234
10,.
11,.
12,.
13,12314123124
;
data want;
set have;
where not missing(my_var);
run;
If you need something else then please please provide what output you require.
Thanks & kind regards,
Amir.
the variable is numeric and I would like to keep the other variables as they are
Thanks for the confirmation.
Does the code I posted give you what you want?
If not then please provide example output data for the given input data.
Kind regards,
Amir.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.