BookmarkSubscribeRSS Feed
R_A_G_
Calcite | Level 5
Please help me out understand this code

Thank you

CALL CATX(" ", NewStruc, OF BeginS--EndS);
NewStruc = TRANWRD(NewStruc, "." , " " );
NewStruc = STRIP(NewStruc);
NewStrucAdd = TRANWRD(STRIP(NewStruc), " " , "+" );
NewStrucAdd = TRANWRD(STRIP(NewStruc), " " , "+" );
* Creating index for longest possible number of structural parms;
LongSParm = LENGTH(STRIP(NewStruc));
run;
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
Since you only posted partial code, it is hard to help. Also, some idea of the data is needed for example, what is in the variable BeginS and the variable EndS?? And, since the OF refers to a NAME RANGE LIST, as described here:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000695105.htm
... it would be useful to know what OTHER variables are being included in this list.

To me it looks like a variable called NewStruc is being created from the concatenated variable values in the OF list. Then, some additional functions are being used to alter the value and store the altered value in the NewStrucAdd variable. Then, the LENGTH function is used to find the length of the NewStruc variable. Since that is the only line that's commented, perhaps the comment "Creating index for longest possible number of structural parms" means something in the context of the program or the task.

More information about these functions and call routines can be found here:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002256379.htm
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002295689.htm
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000215027.htm
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000245907.htm


One thing you can do to help yourself figure out what's happening is to use PUT or PUTLOG statements to help you understand each transformation. Something like:
[pre]
putlog '**** BEFORE CALL CATX';
putlog _all_;
CALL CATX(" ", NewStruc, OF BeginS--EndS);
putlog NewStruc=;

NewStruc = TRANWRD(NewStruc, "." , " " );
putlog '**** after TRANWRD';
putlog NewStruc=;

NewStruc = STRIP(NewStruc);
putlog '** after STRIP';
putlog NewStruc=;

NewStrucAdd = TRANWRD(STRIP(NewStruc), " " , "+" );
putlog '** after first TRANWRD;
putlog NewStruc= NewStrucAdd=;

NewStrucAdd = TRANWRD(STRIP(NewStruc), " " , "+" );
putlog '** after second TRANWRD;
putlog NewStruc= NewStrucAdd=;

* Creating index for longest possible number of structural parms;
LongSParm = LENGTH(STRIP(NewStruc));
putlog '** end of transformations';
putlog LongSParm=;
run;
[/pre]

And then review the results in the SAS log, as you refer to the documentation.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 572 views
  • 0 likes
  • 2 in conversation