what is the difference between x=substr(name,1,2);
and substr(name,1,2)='x';

Answer Posted / sattwik panda

x=substr(name,1,2) will return first two character of a string whereas substr(name,1,2)='x' will replace first two character by 'x'.
Please try using the code below to get an idea.
data test;
name="Sattwik";
x=substr(name,1,2);
substr(name,1,2)='x';
run;

x will have the first two characters of name:'Sa'.
substr(name,1,2)='x' will replace first two characters of "Sattwik". So, now the name will contain "xttwik".

Is This Answer Correct ?    46 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you execute macro within another macro? : sas-macro

784


What is the difference between SAS functions and procedures?

933


what is star schema? : Sas-di

897


what does the run statement do? : Sas programming

822


what is the purpose of _error_? : Sas programming

896


What do the PUT and INPUT functions do?

1054


What are the default statistics that proc means produce?

826


name some data transformation used in sas di? : Sas-di

771


describe the interaction table in sas di? : Sas-di

823


Given an unsorted data set, how to read the last observation to a new data set?

1134


what is transformation in sas data integration? : Sas-di

810


What is a pdv and what are its functions?

827


: and & modifiers.

1154


do you prefer proc report or proc tabulate? Why? : Sas programming

810


This entry was posted in General. Bookmark the permalink. Post a comment or leave

4379