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 |
sas macros
What is proc sql pass through facility?
what is transformation in sas data integration? : Sas-di
what is program data vector? : Sas-administrator
diff between nodup rec and ondup key???
How to create an external dataset with sas code?
What are SAS/ACCESS and SAS/CONNECT?
what do the pad and dim functions do? : Sas programming
Do you need to combine data sets? How should you combine data sets– MERGE or SET statements in DATA steps,PROC APPEND,PROC SQL?
why is a stop statement needed for the point=option on a set statement? : Sas programming
How would you delete duplicate observations?
how can you sort the dataset having millions of OBS(instead of sort procedure?