Help using Base SAS procedures

need help

Reply
Regular Contributor
Posts: 161

need help

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;
SAS Super FREQ
Posts: 8,862

Re: need help

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
Ask a Question
Discussion stats
  • 1 reply
  • 102 views
  • 0 likes
  • 2 in conversation