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

Hello folks
I have the thankless task to rewrite undocumented SAS code. At one point a DATA step references CMPLIB=. Fortunately the referenced file is still available, unfortunately not the SAS program that generates the functions it contains. However, this SAS file contains "data lines" that contain commands and some kind of BEGIN / END logic. Do you know a way to "translate" the contained functions back into DATA step code?

Please share if you ever had such a job.
Kind regards

Hon

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

I assume some user defined functions have been created using Proc FCMP.

 

To list all functions and subroutines, you can use the following code, where work.myfunc is the name you used in the CMPLIB option:


/*
 * get a listing of all function
 */
proc fcmp inlib=work.myfunc listfuncs;
run;

You then get a list of functions/subroutines.

To see the code for an individual function use this code:

/*
 * list code for an individual function
 */
proc fcmp inlib=work.myfunc;
  listfunc kt_convert;
run;

Whenever you see a line like _yourFunctionName_ = ...;, this is the RETURN statement in the function definition.

 

Similar to the LISTFUNC statement there is the LISTSUBR statement to list the code for a subroutine.

View solution in original post

2 REPLIES 2
BrunoMueller
SAS Super FREQ

I assume some user defined functions have been created using Proc FCMP.

 

To list all functions and subroutines, you can use the following code, where work.myfunc is the name you used in the CMPLIB option:


/*
 * get a listing of all function
 */
proc fcmp inlib=work.myfunc listfuncs;
run;

You then get a list of functions/subroutines.

To see the code for an individual function use this code:

/*
 * list code for an individual function
 */
proc fcmp inlib=work.myfunc;
  listfunc kt_convert;
run;

Whenever you see a line like _yourFunctionName_ = ...;, this is the RETURN statement in the function definition.

 

Similar to the LISTFUNC statement there is the LISTSUBR statement to list the code for a subroutine.

HoneyBieny
Calcite | Level 5

Bruno, That's one big step forward! I was a bit lost what to do next. Thanks a lot! HB

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!

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
  • 2 replies
  • 342 views
  • 3 likes
  • 2 in conversation