Pipeline question/discussion about the << Operator.<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />I've read in the manual (Scripting Guide, Ch 11) where it explains about 'Nesting and Precedence' and wondered if others would like to have an option that would act more like a pipeline operator (not unlike the %>% magrittr operator in R). So instead of having to nest your stacked messages with parentheses like
( (object<
it would be more readable and naturally flow from left to right
object %>>% message1
%>>% message2
%>>% message3
Re: Question/discussion about the << Operator.You could do this. It might not be the best approach for future maintenance; a well named variable can clarify a lot.
dt=open("C:\Program Files\SAS\JMPPRO\13\Samples\Import Data\bigclass_L.txt")
<
<
<
You can make the invertRowSelection go away by changing the selectWhere condition.
This works because I picked messages that don't create a new object (like <
Six months later, I'd rather maintain something a bit less monolithic:
allData = Open( "C:\Program Files\SAS\JMPPRO\13\Samples\Import Data\bigclass_L.txt" );
ageSubset = allData << selectwhere( 13 <= :age <= 15 ) << subset( selected rows( 1 ) );
tenRows = ageSubset << selectwhere( Row() <= 10 ) << subset( selected rows( 1 ) );
tenRows << New Column( "halfage", formula( age / 2 ) );
Close( allData, nosave );
Close( ageSubset, nosave );
Re: Question/discussion about the << Operator.to motivate... I wondered how others would script this R/magrittr example in JSL, where they explain:
Four operations are performed to arrive at the desired data set, and they are written in a natural order: the same as the order of execution. Also, no temporary variables are needed. If yet another operation is required, it is straight-forward to add to the sequence of operations wherever it may be needed.
the_data <-
read.csv('/path/to/data/file.csv') %>%
subset(variable_a > x) %>%
transform(variable_c = variable_a/variable_b) %>%
head(100)