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

CSV2DS - files with missing column names #4

Closed
gusfryk01 opened this issue Oct 6, 2023 · 3 comments
Closed

CSV2DS - files with missing column names #4

gusfryk01 opened this issue Oct 6, 2023 · 3 comments

Comments

@gusfryk01
Copy link

I recently tried to import a CSV-file with one column name missing and I tried doing that with your CSV2DS macro.
It resulted in an error.
The following statement, in the data step that creates TYPES, solves that problem and doesn't impact the way the macro words when there are no missing column names.

if missing(name) then name=upcase;

@sasutils
Copy link
Owner

sasutils commented Nov 7, 2023

The current code should already be replacing empty names with VARnnn where nnn is the variable number. Can you provide an example file that causes the trouble?

@sasutils
Copy link
Owner

sasutils commented Nov 7, 2023

The only way I could re-create something like that problem is to (1) have VALIDVARNAME=ANY set. (2) Write the CSV file using TERMSTR=CRLF (3) Tell %CSV2DS() to read the file using TERMSTR=LF. In that case it will create a variable whose name is the single CR character that it read from the file. Which when printed will look a lot like a space.

@sasutils sasutils closed this as completed Nov 7, 2023
@sasutils
Copy link
Owner

sasutils commented Nov 7, 2023

Closing this issue. Use the right setting for TERMSTR when reading the file. %csv2ds("myfile.csv" termstr=crlf).

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