BookmarkSubscribeRSS Feed
mlogan
Lapis Lazuli | Level 10

Hi All,

I am importing data from csv to Base sas. Some of the columns in csv is more than 32 characters and therefore can't read by PROC IMPORT properly. Is there a way to increase the length of variable so that sas can accomodate the whole length as it appears on the csv file.

 

Here is the code I was trying:

 

LIBNAME Apple 'C:\MyFolder'; 
OPTIONS FORMDLIM='_';



PROC IMPORT DATAFILE="C:\MyFolder\testfile.csv" 
OUT=Apple.Testfile
DBMS=csv REPLACE;
GETNAMES=YES;
DATAROW=2;
GUESSINGROWS=32000;
RUN;
9 REPLIES 9
Reeza
Super User
No, SAS Variable names are restricted to 32 characters in the current set up. I believe it's changing soon. You can customize the code from the log and change the name there as required and then use that code to import the data.
ballardw
Super User

Not at this time.

However you can assign labels to variables that are up to several hundred characters long.

 

If you are going to read files in this layout more than once I strongly suggest using a data step to control variable names.

I deal with data sources that have column headings (NOT variable names) that consist of up to 200 characters in the CSV file I read. I am not going to program with such garbage.

 

 

novinosrin
Tourmaline | Level 20

 

isn't that 256 characters only(max label length)?

 

Well, i am not aware there's update to that? But if that's coming from you, that should be correct.


@ballardw wrote:

Not at this time.

However you can assign labels to variables that are up to several hundred characters long.

 

 


 

ballardw
Super User

@novinosrin wrote:

 

isn't that 256 characters only(max label length)?

 

Well, i am not aware there's update to that? But if that's coming from you, that should be correct.


@ballardw wrote:

Not at this time.

However you can assign labels to variables that are up to several hundred characters long.

 

 


 


Just pointing out an option, more than 200 is more than "a couple of hundred" and just didn't feel more details needed at the moment.

novinosrin
Tourmaline | Level 20

Oh ok sorry.

Kurt_Bremser
Super User

Never assume, just because we old hands are old hands, that we know everything better than you. Be ready to question any statement when you feel that you know better.

We probably have forgotten more about SAS than you have managed to learn in your presumably short career, but that only means that there is a lot where you may be right, while we're not.

Reeza
Super User
Things have changed in the last 15 years and some of the methods I use are still from then....don't always remember the 'best' way since it keeps changing!
novinosrin
Tourmaline | Level 20

Thank you sir @Kurt_Bremser   for the beautiful and encouraging words. I like that amazing attitude in wise not old folks like you in filling new folks in the spectrum. While I acknowledge and agree, I must opine arguably older are not older rather wiser and on the contrary the younger ones across the globe are mostly chaos(me very much included being naughty-- not willing to listen and learn) barring a selected disciplined few. Well well, we see that everyday in our streets, metro trains and all walks of life.

 

Sometimes, I wonder how my parents managed to raise their only child and am glad they are seeing changes though late than never. For what I remember, had I been sincere, attentive and disciplined early on, I would have probably enjoyed finer things in life much earlier.

 

Well, Good things are happening to me by chance, I wish it happened to me by choice and attentive en-devour.

On that note a funny but real and serious truth. I was a fork lift driver at IKEA, Wednesfield in England while attempting to do my undergrad to get that damn degree to keep my parents happy with no interest in it. Anyway, So, Pub was daily routine and we were all well over tipsy. A guy asked -"what do i do for a living". Feeling embarrassed to tell the truth that I am blue collar worker, I replied I work in supply chain logistics haha to sound like a white collar. Then he says, learn SAS and that will be helpful, and much to my surprise it really has been a better addiction than play station/Xbox. His name was Marcin and he was from Munich,  since then paulaner dark dunkel continues to be my favorite 🙂

 

Thank you for reading!

 

 

.  

 

 

Kurt_Bremser
Super User

SAS has a hard limit of 32 characters (bytes) for variable and dataset names. You can put longer descriptions in variable labels.

Copy the data step that proc import creates out of the log and adapt it to your needs.

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 9 replies
  • 13178 views
  • 11 likes
  • 5 in conversation