BookmarkSubscribeRSS Feed
ChuksManuel
Pyrite | Level 9

Hi programmers,

 

I imported a .dat file in SAS and the variable name (column name) is missing and replaced by VAR1, VAR2, VAR3 etc. Is there any reason for this?

I have attached my import code

PROC IMPORT DATAFILE = "C:/Users/data_NEW.dat"
OUT = form_Q3
DBMS = DLM REPLACE;
DELIMITER="|";
RUN;

ChuksManuel_0-1651682422857.png

 

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Show us a portion of the input data file.

--
Paige Miller
Tom
Super User Tom
Super User

@ChuksManuel wrote:

Hi programmers,

 

I imported a .dat file in SAS and the variable name (column name) is missing and replaced by VAR1, VAR2, VAR3 etc. Is there any reason for this?

I have attached my import code

PROC IMPORT DATAFILE = "C:/Users/data_NEW.dat"
OUT = form_Q3
DBMS = DLM REPLACE;
DELIMITER="|";
RUN;

ChuksManuel_0-1651682422857.png

 


Yes. PROC IMPORT is too stupid to read header lines that are longer than 32K bytes.

You could try:

  • Add the names back yourself by reading the first row as data and using it to generate a RENAME statement.
  • Write your own data step to read that delimited text file.  Then you have complete control over the names and the types and whether any formats or labels need to be attached to the variables.
  • Use a tool to guess how to read the file that can read the whole header line.  Like : https://github.com/sasutils/macros/blob/master/csv2ds.sas

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 728 views
  • 1 like
  • 3 in conversation