Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for valid variable names when reading data #3

Open
kylebarron opened this issue Nov 6, 2018 · 4 comments
Open

Check for valid variable names when reading data #3

kylebarron opened this issue Nov 6, 2018 · 4 comments

Comments

@kylebarron
Copy link
Owner

I.e. you can't name a variable float

@mcaceresb
Copy link

I do this in two parts. First I loop through to make valid theoretical Stata names in mata here, but that doesn't check reserved names, which I do later on here.

You can just do this in one step, though, because strtoname() is also a regular Stata function. So you can run strtoname, check for conflicts, and rename appropriately. I just added a counter (1, 2, 3, etc.).

@kylebarron
Copy link
Owner Author

The Java api has a function makevarname, and that automatically tests to see if the varname is valid

@mcaceresb
Copy link

Very cool. Be sure to check if it just converts characters or if it also checks for reserved names.

@kylebarron
Copy link
Owner Author

It sounds like it returns null if the variable name can't be created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants