what is the difference between x=substr(name,1,2);
and substr(name,1,2)='x';
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / oanhntt
x=substr(name,1,2) means you assign x value equal to the
first 2 characters of variable "name" while
substr(name,1,2)='x' just compare these fist 2 characters to
value 'x', so this seem useless without condition syntax
(correct one should be: if substr(name,1,2)='x' then /*do
some thing*/;).
| Is This Answer Correct ? | 4 Yes | 16 No |
what are the categories that sas informats are used to the place the data? : Sas-administrator
What SAS statements would you code to read an external raw data file to a DATA step?
What Proc glm does?
How does Mr.Lanka Srinivas teach SAS? Are his accomplishments real? What are the future prospects for SAS?
List down the reasons for choosing sas over other data analytics tools.
In the SAS Data step what is the difference between the subsetting done by Where and subsetting done by If?
What function CATX syntax does?
Code the MEANS to produce output to be used later.
What is PROC in SAS?
Where do the database management systems store data and how do u import them.
what are the three main credit bureau names
1 Answers Synchrony Financial,
what is the difference between x=substr(name,1,2); and substr(name,1,2)='x';