BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
VISHNU239
Obsidian | Level 7

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?

 

  1. FA
  2. FA1
  3. FA 1
  4. ‘‘(missing character value)

 

Answer: A

 

 

 

how is it option A?

1 ACCEPTED SOLUTION

Accepted Solutions
art297
Opal | Level 21

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

 

View solution in original post

3 REPLIES 3
art297
Opal | Level 21

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

 

VISHNU239
Obsidian | Level 7
yeah got it sir. examples helped me in understanding. what does the symbol || mean and what is its function?
art297
Opal | Level 21

|| 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

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1435 views
  • 1 like
  • 2 in conversation