BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

data s ;

name='a@b@c' ;

new=scan(name,2,'@') ;

run;

 

i run above program in 9.2 sas version it gives default length 200

but if i run same program in 9.4 sas version it gives same length like name length is 5 and new variable length is also 5.

can you explain that difference?

3 REPLIES 3
andreas_lds
Jade | Level 19

The documentation is available online for free and i am 100% sure it explains the change.

 

From my point of view: sas fixed a bad design decision with 9.4

Kurt_Bremser
Super User

Maxim 1: Read the Documentation.

 

From the documentation of the SCAN() function:

 

In a DATA step, if the SCAN function returns a value to a variable that has not yet been given a length, that variable is given the length of the first argument. This behavior is different from the behavior in previous releases of SAS. In previous releases, code that created a variable with a length of 200 might have produced a variable with a length that was greater than expected. If you need the SCAN function to assign a variable with a value that is different from the length of the first argument, use a LENGTH statement.

 

This documentation is found by:

Go to documentation.sas.com

Open "SAS 9.4 and SAS Viya 3.4 Programming Documentation"

In the navigation pane to the left, select:

Data Step Programming

Functions and CALL Routines

Dictionary of Functions and CALL Routines

scroll down to the SCAN function and select it

 

All other documentation pertinent to SAS programming is found in the same way, just follow the proper navigation paths.

ballardw
Super User

@thanikondharish wrote:

data s ;

name='a@b@c' ;

new=scan(name,2,'@') ;

run;

 

i run above program in 9.2 sas version it gives default length 200

but if i run same program in 9.4 sas version it gives same length like name length is 5 and new variable length is also 5.

can you explain that difference?


And when I open the online help for SAS as installed the first section is labeled: What's new and provides links to http://support.sas.com/documentation/whatsnew/

with a bunch of by version topics.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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
  • 3 replies
  • 2168 views
  • 0 likes
  • 4 in conversation