From pd@lgd @ending from gm@il@com  Wed Jul  4 23:09:15 2018
From: pd@lgd @ending from gm@il@com (peter dalgaard)
Date: Wed, 4 Jul 2018 23:09:15 +0200
Subject: [Rd] 
 [R] R is creating a new level which is emty after importing a
 SAS file
In-Reply-To: <CY4PR05MB31573C71D954314DD86AA2F2A8410@CY4PR05MB3157.namprd05.prod.outlook.com>
References: <CY4PR05MB31573C71D954314DD86AA2F2A8410@CY4PR05MB3157.namprd05.prod.outlook.com>
Message-ID: <58657783-39C2-454E-8CFD-EEA771BE1688@gmail.com>

It is not obvious that this is an error. If your nominal variable in SAS has a level which is not present in data, then R might just be making a faithful translation. There is a distinction between (a) having a gender variable with two levels of which 0 females and (b) pretending that male is the only possible gender.

Anyways, droplevels() is your friend. (Notice that it easier to remove levels that you do not want than to insert levels that have been unwantedly deleted on input.) 

-pd

> On 4 Jul 2018, at 19:16 , Adam Z. Jabir <Adam.Z.Jabir at outlook.fr> wrote:
> 
> Hi,
> 
> I have imported some sasdata into R using the sas7bdat package. I have some nominal variables with some missing values.
> 
> R is creating a new level which is emty ?.When I ask for tabulate this new level is presented with 0 as a frequency.
> 
> I want to get rid of this level and have my file imported correctly.
> 
> Do you have some hint to help solve this problem?
> 
> 
> Please use this email adress to answer this query.
> 
> 
> Best,
> 
> Adam
> 
> 
> Envoy? ? partir de Outlook<http://aka.ms/weboutlook>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Office: A 4.23
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] [R] R is creating a new level which is emty after importing a SAS file
peter dalgaard