BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cphd
Obsidian | Level 7

 

Some of the variables in my dataset contains more than 32 characters, thus I cannot import them to SAS. Can anyone help to solve this problem? Thank you.

Code that I use ---------------------------------------


data z0420T.BorrowerMailAddress; infile 'H:\Z\13\13 (8)\ZTrans\BorrowerMailAddress.txt' firstobs=1 dsd dlm='|' truncover; BorrowerMailSequenceNumber:2. BorrowerMailCareOfName:$250. BorrowerMailHouseNumber:$13. BorrowerMailHouseNumberExt:$10. BorrowerMailStreetPreDirectional:$2. BorrowerMailStreetName:$50. BorrowerMailStreetSuffix:$6. BorrowerMailStreetPostDirectional BorrowerMailBuildingName:$45. BorrowerMailBuildingNumber:$15. BorrowerMailFullStreetAddress:$80. BorrowerMailCity:$45. BorrowerMailState:$2. BorrowerMailZip:$5. BorrowerMailZip4:$4. OriginalBorrowerMailFullStreetAddress OriginalBorrowerMailAddressLastline BorrowerMailAddressStndCode:$1. BorrowerMailAddressMatchCode:$1. BorrowerMailAddressUnitDesignatorCode BorrowerMailAddressUnitNumber:$11. BorrowerMailAddressCarrierRoute:$4. BorrowerMailAddressFIPSCode:$5. BorrowerMailAddressLatitude:9.6 BorrowerMailAddressLongitude:9.6 BorrowerMailAddressCensusTractAndBlock BorrowerMailAddressConfidenceScore BorrowerMailAddressCBSACode:4. BorrowerMailAddressCBSADivisionCode BorrowerMailAddressMatchType:1. BorrowerMailAddressDPV:$1. BorrowerMailAddressGeocodeQualityCode BorrowerMailAddressQualityCode LoadID:8. FIPS:$5. BatchID:4. ; run;

Log file------------------------------------------------

6709 data z0420T.BorrowerMailAddress;
6710 infile 'H:\Z\13\13 (8)\ZTrans\BorrowerMailAddress.txt' firstobs=1 dsd dlm='|'
6710! truncover;
6711 input TransId:$50.
6712 BorrowerMailSequenceNumber:2.
6713 BorrowerMailCareOfName:$250.
6714 BorrowerMailHouseNumber:$13.
6715 BorrowerMailHouseNumberExt:$10.
6716 BorrowerMailStreetPreDirectional:$2.
6717 BorrowerMailStreetName:$50.
6718 BorrowerMailStreetSuffix:$6.
6719 BorrowerMailStreetPostDirectional
6720 BorrowerMailBuildingName:$45.
ERROR: The variable named BorrowerMailStreetPostDirectional contains more than 32 characters.
6721 BorrowerMailBuildingNumber:$15.
6722 BorrowerMailFullStreetAddress:$80.
6723 BorrowerMailCity:$45.
6724 BorrowerMailState:$2.
6725 BorrowerMailZip:$5.
6726 BorrowerMailZip4:$4.
6727 OriginalBorrowerMailFullStreetAddress
6728 OriginalBorrowerMailAddressLastline
ERROR: The variable named OriginalBorrowerMailFullStreetAddress contains more than 32 characters.
6729 BorrowerMailAddressStndCode:$1.
ERROR: The variable named OriginalBorrowerMailAddressLastline contains more than 32 characters.
6730 BorrowerMailAddressMatchCode:$1.
6731 BorrowerMailAddressUnitDesignatorCode
6732 BorrowerMailAddressUnitNumber:$11.
ERROR: The variable named BorrowerMailAddressUnitDesignatorCode contains more than 32 characters.
6733 BorrowerMailAddressCarrierRoute:$4.
6734 BorrowerMailAddressFIPSCode:$5.
6735 BorrowerMailAddressLatitude:9.6
6736 BorrowerMailAddressLongitude:9.6
6737 BorrowerMailAddressCensusTractAndBlock
6738 BorrowerMailAddressConfidenceScore
ERROR: The variable named BorrowerMailAddressCensusTractAndBlock contains more than 32 characters.
6739 BorrowerMailAddressCBSACode:4.
ERROR: The variable named BorrowerMailAddressConfidenceScore contains more than 32 characters.
6740 BorrowerMailAddressCBSADivisionCode
6741 BorrowerMailAddressMatchType:1.
ERROR: The variable named BorrowerMailAddressCBSADivisionCode contains more than 32 characters.
6742 BorrowerMailAddressDPV:$1.
6743 BorrowerMailAddressGeocodeQualityCode
6744 BorrowerMailAddressQualityCode
ERROR: The variable named BorrowerMailAddressGeocodeQualityCode contains more than 32 characters.
6745 LoadID:8.
6746 FIPS:$5.
6747 BatchID:4.
6748 ;
6749 run;

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set Z0420T.BORROWERMAILADDRESS may be incomplete. When this step was stopped
there were 0 observations and 29 variables.
WARNING: Data set Z0420T.BORROWERMAILADDRESS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.08 seconds
cpu time 0.01 seconds

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Real simple. SAS currently has a hard limit of 32 characters for any variable name.

Period.

Since you are providing the names you have to follow that rule.

Suggestion: When you have a common phrase in almost every variable such as BorrowerMail then either abbreviate or drop completely.

 

SAS has a LABEL that you can assign to a variable that can hold many more characters if you want to have a better description of your variable

 

label SequenceNumber = "Borrower Mail Sequence Number";

for example. Label not only can be longer but can by grammatically correct or at least nice text than a variable name.

 

Personally the only time a "City", as an example, in my data gets any prefix or suffix is when there are two or more cities in the set.

View solution in original post

2 REPLIES 2
ballardw
Super User

Real simple. SAS currently has a hard limit of 32 characters for any variable name.

Period.

Since you are providing the names you have to follow that rule.

Suggestion: When you have a common phrase in almost every variable such as BorrowerMail then either abbreviate or drop completely.

 

SAS has a LABEL that you can assign to a variable that can hold many more characters if you want to have a better description of your variable

 

label SequenceNumber = "Borrower Mail Sequence Number";

for example. Label not only can be longer but can by grammatically correct or at least nice text than a variable name.

 

Personally the only time a "City", as an example, in my data gets any prefix or suffix is when there are two or more cities in the set.

cphd
Obsidian | Level 7
Thank you for your quick reply. I followed other solutions and waited a day for this!!! It was really simple as you said... Thank you so much again!

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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
  • 11274 views
  • 0 likes
  • 2 in conversation