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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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