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?
Answer: A
how is it option A?
Because the length of JobCategory is set as 2.
Now, just as interesting, try to figure out the results of:
data work.staff; JobCategory = 'FA'; JobLevel = '1'; Jobcategory2 = Jobcategory || JobLevel; Jobcategory = Jobcategory || JobLevel; output; JobCategory = 'FAA'; JobLevel = '2'; Jobcategory2 = Jobcategory || JobLevel; Jobcategory = Jobcategory || JobLevel; output; run;
Art, CEO, AnalystFinder.com
Because the length of JobCategory is set as 2.
Now, just as interesting, try to figure out the results of:
data work.staff; JobCategory = 'FA'; JobLevel = '1'; Jobcategory2 = Jobcategory || JobLevel; Jobcategory = Jobcategory || JobLevel; output; JobCategory = 'FAA'; JobLevel = '2'; Jobcategory2 = Jobcategory || JobLevel; Jobcategory = Jobcategory || JobLevel; output; run;
Art, CEO, AnalystFinder.com
|| is similar to the catt function, i.e., it combines strings without trimming spaces from the right or removing any leading spaces.
Art, CEO, AnalystFinder.com
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.