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

Hello,

 

I've added a string field and then I later try to add a string to that column when a certain condition is met. However, the results bring back only up to 7 character cutting off the rest of the text (i.e. Account instead of Account Activity).

 

I set the character limit to 30 as is highlighted in bold font. Can someone explain why my text is getting cut off and what a simple fix might be?

 

proc sql;

alter table alias.table_name
add column_name char format=$CHAR30.;
quit;

 

PROC SQL;
UPDATE alias.table_name
SET program ='Account Activity', tactic = 'Pre-Renewal'
where comm_code like '%855%';
QUIT;

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@schlotty23 wrote:

 Hi Reeza,

 

Thanks for the reply. I tried it an it did not work. I received the error below:

 

25 add tactic char format=$CHAR. length = $30;
_
22
200
ERROR 22-322: Expecting an integer constant.

ERROR 200-322: The symbol is not recognized and will be ig


 

Best when posting errors is to post the entire proc or data step from the log into a code box opened with the forum {I} menu icon.

Note the _ in you post? That would be under the character in the line that actually has the syntax error SAS detected. The message windows on the forum reformat text, especially removing leading blanks, so the _ appears in the wrong place.

 

the Format $char requires an integer in the range 1 to 32767 when assigned as a property of a variable. That integer will be the maximum number of characters shown by default. It need not match the length of a variable: format=$char7. length=$30 would set the storage length of the variable to 30 characters but by default only display 7.

View solution in original post

4 REPLIES 4
Reeza
Super User

Try specifying the length instead. 

proc sql;
alter table alias.table_name
add column_name char format=$30. length = $30;
quit;

 

 

Dogo23
Quartz | Level 8

 Hi Reeza,

 

Thanks for the reply. I tried it an it did not work. I received the error below:

 

25 add tactic char format=$CHAR. length = $30;
_
22
200
ERROR 22-322: Expecting an integer constant.

ERROR 200-322: The symbol is not recognized and will be ig

ballardw
Super User

@schlotty23 wrote:

 Hi Reeza,

 

Thanks for the reply. I tried it an it did not work. I received the error below:

 

25 add tactic char format=$CHAR. length = $30;
_
22
200
ERROR 22-322: Expecting an integer constant.

ERROR 200-322: The symbol is not recognized and will be ig


 

Best when posting errors is to post the entire proc or data step from the log into a code box opened with the forum {I} menu icon.

Note the _ in you post? That would be under the character in the line that actually has the syntax error SAS detected. The message windows on the forum reformat text, especially removing leading blanks, so the _ appears in the wrong place.

 

the Format $char requires an integer in the range 1 to 32767 when assigned as a property of a variable. That integer will be the maximum number of characters shown by default. It need not match the length of a variable: format=$char7. length=$30 would set the storage length of the variable to 30 characters but by default only display 7.

Reeza
Super User

That isn't the code I posted...but yes, there is a mistake in it. 

 

data class;
set sashelp.class;
run;

proc sql;
alter table class
add age_category char format=$30. length=30;
quit;

proc sql;
update class
set age_category='Tween           Test Value'
where age < 13;
quit;

proc print data=class;run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 7407 views
  • 1 like
  • 3 in conversation