Professional Documents
Culture Documents
Lesson 2 Challenge Practice Using The CALL PRXSUBSTR Routine
Lesson 2 Challenge Practice Using The CALL PRXSUBSTR Routine
Reminder: If you restarted your SAS session, open and submit the libname.sas program in the course
files.
1. Open the p302p06.sas program in the practices folder. Run the program to view the Column1
values. The park codes follow a "C:" or "Code:" prefix. What are the characteristics of the codes?
The park codes consist of three or more uppercase letters enclosed in double quotation marks.
Note: Use the SAS documentation (SAS Functions and CALL Routines: Reference) to learn about
the CALL PRXSUBSTR routine.
data work.ParkCodes;
set pg3.np_unstructured_codes;
Expression='/[A-Z]{3}[A-Z]*/o';
PatternId=prxparse(Expression);
call prxsubstr(PatternID,Column1,MyStart,MyLength);
run;
run;
title;
3. Run the program. What are the values of the MyStart and MyLength columns in row 1 and row 7?
4. Use the SUBSTR function to create a column named ParkCode based on the MyStart and
MyLength columns.
/* p302p06_s.sas */
data work.ParkCodes;
set pg3.np_unstructured_codes;
Expression='/[A-Z]{3}[A-Z]*/o';
https://vle.sas.com/pluginfile.php/565533/mod_scorm/content/17/02/epg3m602_2_p_l3.htm 1/2
13/02/2022, 19:10 Practice
PatternId=prxparse(Expression);
call prxsubstr(PatternID,Column1,MyStart,MyLength);
ParkCode=substr(Column1,MyStart,MyLength);
run;
run;
title;
5. Run the program and verify the ParkCode values. What are the values of ParkCode in rows 1 and
7?
Hide Solution
https://vle.sas.com/pluginfile.php/565533/mod_scorm/content/17/02/epg3m602_2_p_l3.htm 2/2