BookmarkSubscribeRSS Feed
Jarvin99
Obsidian | Level 7

I cannot import dta file into SAS. I know that my variable name is probably too long, but I do not know how to fix it. How short should it be? Btw, is my code correct to import dta file into SAS?

 

Here is my code:

proc import datafile='F:\Dropbox\Dataset\BoardEx\data\NorthAmerica_full\Announcements\BoardandDirectorAnnouncements\raw\BoardandDirectorAnnouncements_199901to202011\announcement_short.dta'
out=cards
dbms=dta
replace;

 

Here is the log:

1 proc import
1 ! datafile='F:\Dropbox\Dataset\BoardEx\data\NorthAmerica_full\Announcements\BoardandDirecto
1 ! rAnnouncements\raw\BoardandDirectorAnnouncements_199901to202011\announcement_short.dta'
2 out=cards
3 dbms=dta
4 replace;

Didn't see end for |varnames| element. Got -> ||
Requested Input File Is Invalid
ERROR: Import unsuccessful. See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 13.71 seconds
cpu time 0.81 seconds

 

5 proc import
5 ! datafile='F:\Dropbox\Dataset\BoardEx\data\NorthAmerica_full\Announcements\BoardandDirecto
5 ! rAnnouncements\raw\BoardandDirectorAnnouncements_199901to202011\announcement_short.dta'
6 out=cards
7 dbms=dta
8 replace;

 

Kindly help me. I just started using SAS for 2 weeks. Very new to this, and my data has 113mb, very large. Thank you.

2 REPLIES 2
LinusH
Tourmaline | Level 20

I don't know how PROIC IMPORT manages varibel name lengths, Stata files specifically.

But the best if you can adjust it at the source, and try to limit to 32 chars, following SAS naming conventions if possible.

Data never sleeps
ballardw
Super User

If you have OPTIONS VALIDVARNAME=V7; set then proc import will truncate variable names and provide warnings in the log about log names. The option will also replace any non-standard characters in the variable names with _.

If you have multiple long variable names where the first 32 characters are the same you may see the second and subsequent variables with 31 characters the same and a suffix number indicating order of appearance.

 

You may find that your DTA file is not the expected DTA DBMS type as many applications over the years have used that extension and is not restricted to only the STATA file that Proc Import expects. A quick search shows

Stata Data File
Zeiss BIVAS Image
Chain Calculator Database
EZ-Forms Data File
Sonic Robo Blast 2 WAD Data
Atari Jaguar Binary Image

Three of these are image files of a sort, and likely would not be candidates for "data" in the SAS meaning for Proc Import which expects rows and columns(variables) of consistent structure.

 

A file name with "Announcement" in the name does not sound promising to me as such data. You may be able to examine the file properties (right click on the file and use the menu) to see which application created the file.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1854 views
  • 0 likes
  • 3 in conversation