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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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