The following SAS program is submitted:
data work.staff;
JobCategory = 'FA';
JobLevel = '1';
JobCategory = JobCategory || JobLevel;
run;
Which one of the following is the value of the variable JOBCATEGORY in the output data set?
A. FA
B. FA1
C. FA 1
D. ' ' (missing character value)
Click Comment link to get answer
B
ReplyDeleteWRONG!!!! YOU SO STUPID!!!!
DeleteA
ReplyDeleteCorrect Ans: A
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteYa ..its A
ReplyDeletelength of JobCategory already set to 2 by the first assignment statement
it is not because of length man;
Deletechange the 4th line to
JobCategory1=JobCategory || JobLevel;
no because you are using the same name for the variable the Jobcategory variable is automatically assigned to 2. So yo have to manually set the length to 3 or 4.
DeleteHuh? I dont understand what this line is supposed to mean:
ReplyDeleteJobCategory = JobCategory JobLevel;
But when u try to run it, the program stops working because of syntax errors.
There is a typo, it should be
ReplyDeleteJobCategory = JobCategory || JobLevel;
I will update the questions. Thanks for pointing it out.
A
ReplyDeleteThanks Jungs you have the write explaination
ReplyDeleteAnswer is A
Answer is A
ReplyDeletereason:
jobcategory='FA';
after this jobcategory variable's length is two bytes,it can hold only two bytes.
Eventhough there is no mistake in the step
jobcategory=jobcategory//joblevel;
jobcategory carries the value FA.
If they wanted under new variable NewJobCat then it would have
ReplyDeleteFA / 1 ( with little distance because it needs trim to stay closer to FA).
No, it will output FA1 if store it in new variable. i just run it with new variable and it outputted FA1
DeleteAns A:
ReplyDeletebehind the scenes:
1. the PDV writes the variables jobcategory (length 2) joblevel (length 1)with missing values
2. at the execution jobcategory gets FA and joblevel gets 1
3. the concatenation overrides the variable jobcategory with FA1 but because the length of that variable is 3, the 1 is excluded.
This comment has been removed by the author.
Deletedata staff;
ReplyDeletelength jobcategory $3;
jobcategory = 'FA';
joblevel ='1';
jobcategory = trim(jobcategory) || joblevel;
*jobcategory = jobcategory || joblevel;
run;
if you define the character length; and use trim function you will have FA1 as answer. Otherwise FA (only two character length) seems to be the answer
This is the reasoning I was waiting for..
DeleteThanks!! :)
Ans is A
ReplyDeleteExplanation--> Actual value of the variable jobcatogery is FA1 How ever since sas first finds the value of Job category as FA it sets the length to 2 hence 1 is finally discarded from FA1 to make up to a length of 2.
shouldn't it be a syntax error and henceforth a missing value since JOBCATEGORY is different from jobcategory?
ReplyDeleteAns is A try in SAS but if you run this prgm as below with new var added then ans be FA1 but now it is FA as length of var is set to 2 in PDV:
ReplyDeletedata work.staff;
JobCategory = 'FA';
JobLevel = '1';
NJobCategory = JobCategory || JobLevel;
run;
A
ReplyDeletewhy is trim function is used when there is no trailing blanks in the above examples?
ReplyDeleteGood post. I learn something totally new and challenging on blogs I stumble upon on a daily basis. It will always be interesting to read articles from other authors and practice something from their websites...
ReplyDeleteBase SAS Training in chennai
A
ReplyDeleteanswer is A
ReplyDeletejobcategory=jobcategory//joblevel;
jobcategory carries the value FA.
A
ReplyDeleteI have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
ReplyDeleteBest PHP Training Institute in Chennai|PHP Course in chennai
Best .Net Training Institute in Chennai
Dotnet Training in Chennai
Dotnet Training in Chennai
Great post very useful info thanks for this post ....
ReplyDeleteAws training chennai | AWS course in chennai
Rpa training in chennai | RPA training course chennai
sas training in chennai | sas training class in chennai
Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of....
ReplyDeleteAws training chennai | AWS course in chennai
Rpa training in chennai | RPA training course chennai
sas training in chennai | sas training class in chennai