Open JackStat opened 10 years ago
Does SAS preserve case in variable names? Frank
On 04/15/2014 04:13 PM, Tyler Hunt wrote:
Being a native R guy I am pretty particular about the case of my variables. I am constantly passing data sets from SAS to R and when I use sas.get it makes everything lower case. Is there a way to preserve the case? An extra option like CamelCase=FALSE would be nice that way it won't break peoples existing programs.
— Reply to this email directly or view it on GitHub https://github.com/harrelfe/Hmisc/issues/7.
In which context?
On Apr 15, 2014 4:14 PM, Tyler Hunt notifications@github.com wrote:
Being a native R guy I am pretty particular about the case of my variables. I am constantly passing data sets from SAS to R and when I use sas.get it makes everything lower case. Is there a way to preserve the case? An extra option like CamelCase=FALSE would be nice that way it won't break peoples existing programs.
— Reply to this email directly or view it on GitHubhttps://github.com/harrelfe/Hmisc/issues/7.
SAS is case insenstive but it does preserve case in it's data sets. I am thinking that we need to modify the sas macro that you are using to read in the data. Give me a day or 2 and I will locate where the case is lost and hopefully restore it. We can then add an option to sas.get that defaults to make variable names all lower case and then use tolower on the R side.
This would only apply to variable names as we preserve case for variable labels. If SAS is case insensitive I'm not sure this matters very much.
On Apr 15, 2014 6:27 PM, Tyler Hunt notifications@github.com wrote:
SAS is case insenstive but it does preserve case in it's data sets. I am thinking that we need to modify the sas macro that you are using to read in the data. Give me a day or 2 and I will locate where the case is lost and hopefully restore it. We can then add an option to sas.get that defaults to make variable names all lower case and then use tolower on the R side.
— Reply to this email directly or view it on GitHubhttps://github.com/harrelfe/Hmisc/issues/7#issuecomment-40542228.
I am required at my job to create all of my data sets in SAS. I use sas.get to pass things to R and would like the option to allow variable case to match across the two programs.
That does not address my question. Please answer it before proceeding with any more coding.
I am not quite sure what your question is... In the SAS macro that is included in sas.get there is a bit of code that converts variable names to lower case. That seems nonsensical to me as I would prefer to retain the case from SAS. Why would you want to change the original case of the variables? It seems that the most logical solution is to handle case on the R side. If users want to continue to change the original case of the variable names then they can specify var.case="lower" which is the default as to not break existing programs out there. Does that help?
Here's the kind of explanation I was looking for, if it's true: SAS does not respect the case of variable names in that aB and ab are treated as the same variable. But SAS preserves the original case of variables when storing the dataset, and shows the original case in the output of PROC CONTENTS and in all other PROC output. When copying a dataset with PROC COPY or a data step, the case is preserved.
If you can confirm all of that then it is worth doing this. Thanks -Frank
That is correct. Thanks.
Being a native R guy I am pretty particular about the case of my variables. I am constantly passing data sets from SAS to R and when I use sas.get it makes everything lower case. Is there a way to preserve the case? An extra option like CamelCase=FALSE would be nice that way it won't break peoples existing programs.