BookmarkSubscribeRSS Feed
adrfinance
Obsidian | Level 7

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?

4 REPLIES 4
Amir
PROC Star

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.

Amir
PROC Star

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.

adrfinance
Obsidian | Level 7

the variable is numeric and I would like to keep the other variables as they are

Amir
PROC Star

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 627 views
  • 0 likes
  • 2 in conversation