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
what is sas metadata server? : Sas-di
Which date function advances a date, time or datetime value by a given interval?
Are you sensitive to code walk-throughs peer review or QC review?
How to import multiple xls files into sas. Out of those files, how to get different values from a single variable and how to find number of rows per value type? We can do this using group by for one xls file with proc sql. Was wondering how I can achieve this for multiple files at the same time. Any ideas?
What can you learn from the SAS log when debugging?
what is function of retain statment
How to create an external dataset with sas code?
what is sas application server? : Sas-di
How do dates work in sas?
What is the command used to find missing values?
Which are the statements whose placement in the data step is critical?
how would you create a data set with 1 observation and 30 variables from a data set with 30 observations and 1 variable? : Sas programming
What are the features of SAS?
what is the purpose of _error_? : Sas programming
what is sas and what are the functions? : Sas-administrator