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

I feel like the practice exam must have been reviewed a thousand times for accuracy, so I feel silly asking this, but I really feel like the answer to Question 9 should be Bobby Bonilla. The question asks for the value of the NewName variable for observation 28 in the output data set:

 

TheresaM_0-1705437270000.png

 

The entire question is:

 

Write a SAS program that will:

 

  • Use PROC FCMP to create a user-defined function called ReverseName to convert the variable name values from lastname, firstname to firstname lastname (Example: convert Wei, Zhang to Zhang Wei) Store the function in work.functions.dev.
    • Use the following formula for the conversion:catx(" ", scan(name,2,","),scan(name,1,","))

  • Create a new data set work.ACT01.
    • Create this data set from the cert.names01 data set.
    • Use the ReverseName function to create a new variable newName from the name variable.
    • work.ACT01 should contain both the name and newName variables.
  • When finished, sort the new data set by the newName variable in ascending order.

The correct code is below and the names.01 dataset is attached here.  

options cmplib=work.functions;
proc fcmp outlib=work.functions.dev;
	function ReverseName(name $) $40;
	return(catx(" ", scan(name,2,","),scan(name,1,",")));
	endsub;
quit;

data work.act01;
	set cert.names01;
	newName=ReverseName(name);
run;

Can someone try this and let me know if I am missing something? The answer key states that the correct response is "Bo Diaz" but that is the value for observation 79.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@TheresaM wrote:

I feel like the practice exam must have been reviewed a thousand times for accuracy, so I feel silly asking this, but I really feel like the answer to Question 9 should be Bobby Bonilla. The question asks for the value of the NewName variable for observation 28 in the output data set:

 

TheresaM_0-1705437270000.png

 

The entire question is:

 

Write a SAS program that will:

 

  • Use PROC FCMP to create a user-defined function called ReverseName to convert the variable name values from lastname, firstname to firstname lastname (Example: convert Wei, Zhang to Zhang Wei) Store the function in work.functions.dev.
    • Use the following formula for the conversion:catx(" ", scan(name,2,","),scan(name,1,","))

  • Create a new data set work.ACT01.
    • Create this data set from the cert.names01 data set.
    • Use the ReverseName function to create a new variable newName from the name variable.
    • work.ACT01 should contain both the name and newName variables.
  • When finished, sort the new data set by the newName variable in ascending order.

The correct code is below and the names.01 dataset is attached here.  

options cmplib=work.functions;
proc fcmp outlib=work.functions.dev;
	function ReverseName(name $) $40;
	return(catx(" ", scan(name,2,","),scan(name,1,",")));
	endsub;
quit;

data work.act01;
	set cert.names01;
	newName=ReverseName(name);
run;

Can someone try this and let me know if I am missing something? The answer key states that the correct response is "Bo Diaz" but that is the value for observation 79.

 

Thanks!


Check the OBSERVATION NUMBER AFTER SORTING

View solution in original post

2 REPLIES 2
ballardw
Super User

@TheresaM wrote:

I feel like the practice exam must have been reviewed a thousand times for accuracy, so I feel silly asking this, but I really feel like the answer to Question 9 should be Bobby Bonilla. The question asks for the value of the NewName variable for observation 28 in the output data set:

 

TheresaM_0-1705437270000.png

 

The entire question is:

 

Write a SAS program that will:

 

  • Use PROC FCMP to create a user-defined function called ReverseName to convert the variable name values from lastname, firstname to firstname lastname (Example: convert Wei, Zhang to Zhang Wei) Store the function in work.functions.dev.
    • Use the following formula for the conversion:catx(" ", scan(name,2,","),scan(name,1,","))

  • Create a new data set work.ACT01.
    • Create this data set from the cert.names01 data set.
    • Use the ReverseName function to create a new variable newName from the name variable.
    • work.ACT01 should contain both the name and newName variables.
  • When finished, sort the new data set by the newName variable in ascending order.

The correct code is below and the names.01 dataset is attached here.  

options cmplib=work.functions;
proc fcmp outlib=work.functions.dev;
	function ReverseName(name $) $40;
	return(catx(" ", scan(name,2,","),scan(name,1,",")));
	endsub;
quit;

data work.act01;
	set cert.names01;
	newName=ReverseName(name);
run;

Can someone try this and let me know if I am missing something? The answer key states that the correct response is "Bo Diaz" but that is the value for observation 79.

 

Thanks!


Check the OBSERVATION NUMBER AFTER SORTING

TheresaM
Obsidian | Level 7

Yes yes yes!  I knew that I was missing something, despite rereading the question a dozen times. This is the type of thing I need to watch out for during the exam.  Thank you @ballardw !!

sas-innovate-2024.png

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.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 300 views
  • 2 likes
  • 2 in conversation