BookmarkSubscribeRSS Feed
smartis
Fluorite | Level 6

Goodmorning everyone!

I uploaded a dataset on Sas Viya for Learners.

My problem is: the NA values are called unknown.. how can I recall them with the classic name: 'NA' so that SAS recognise and process them as NA?

 

Thank you so much!

Martina

5 REPLIES 5
Kurt_Bremser
Super User

I guess(!) that you actually did not upload a dataset, but a data file that was then imported into SAS and has a numeric column with 'NA' in some places. Is that correct?

smartis
Fluorite | Level 6

not really, sorry, probably I didn't explain well myself: 

 

In the dataset I'm working on there are, in different columns, values called 'unknown', when I perform the imputation, SAS tell me that there aren't missing values, but actually there are and they are the unknowns!

 

So know: how can I substitute that 'unknown' into NA's??

 

Thanks in advance

Martina

Kurt_Bremser
Super User

OK, so we need to know

  • the type of the source variable
  • the format assigned to it
  • if character, the defined length will also be good to know
  • the raw content (displayed without a format)

Run a PROC CONTENTS on the dataset. If you find a format attached, run this:

data _null_;
set dataset (obs=10);
format var; /* removes any format */
put var;
run;

(replace "dataset" and "var" with your dataset and variable name, respectively)

This will write the first 10 values to the SAS log, from where you can copy/paste them here.

Reeza
Super User

NAs are a concept in R/Python. 

Nulls/Missing are a DB concept

SAS uses spaces/blanks for character missing and . (period) for numeric missing. 

 

Is this a correct interpretation of your question:

 

  • You have a data set that you're trying to impute missing data 
  • The field is character
  • One of the values in the field is 'unknown' and SAS is not treating the unknown as missing
  • You want to impute for the 'unknown values in the column

If this is correct, you first need to recode the unknown to missing 

 

data missing;
set have;

if varInterest='unknown' then call missing(varInterest);

run;

@smartis wrote:

not really, sorry, probably I didn't explain well myself: 

 

In the dataset I'm working on there are, in different columns, values called 'unknown', when I perform the imputation, SAS tell me that there aren't missing values, but actually there are and they are the unknowns!

 

So know: how can I substitute that 'unknown' into NA's??

 

Thanks in advance

Martina


 

smartis
Fluorite | Level 6

Thank you so much and sorry for my late answer!

Martina

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1258 views
  • 3 likes
  • 3 in conversation