Desktop productivity for business analysts and programmers

Text getting cutoff when adding new value to new table

Accepted Solution Solved
Reply
Contributor
Posts: 55
Accepted Solution

Text getting cutoff when adding new value to new table

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;


Accepted Solutions
Solution
‎12-05-2017 01:28 PM
Super User
Posts: 13,023

Re: Text getting cutoff when adding new value to new table


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


All Replies
Super User
Posts: 22,844

Re: Text getting cutoff when adding new value to new table

Try specifying the length instead. 

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

 

 

Contributor
Posts: 55

Re: Text getting cutoff when adding new value to new table

 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

Solution
‎12-05-2017 01:28 PM
Super User
Posts: 13,023

Re: Text getting cutoff when adding new value to new table


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.

Super User
Posts: 22,844

Re: Text getting cutoff when adding new value to new table

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;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 260 views
  • 1 like
  • 3 in conversation