Coder Social home page Coder Social logo

vb6hobbyst7 / utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rogerjdeangelis/utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion

0.0 2.0 0.0 8 KB

Vectorized solution to finding *first* element in a row meeting criterion. Keywords: sas sql join merge big data analytics macros oracle teradata mysql sas communities stackoverflow statistics artificial inteligence AI Python R Java Javascript WPS Matlab SPSS Scala Perl C C# Excel MS Access JSON graphics maps NLP natural language processing machine learning igraph DOSUBL DOW loop stackoverflow SAS community.

License: MIT License

SAS 100.00%

utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion's Introduction

utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion

Vectorized solution to finding first element in a row meeting criterion. Keywords: sas sql join merge big data analytics macros oracle teradata mysql sas communities stackoverflow statistics artificial inteligence AI Python R Java Javascript WPS Matlab SPSS Scala Perl C C# Excel MS Access JSON graphics maps NLP natural language processing machine learning igraph DOSUBL DOW loop stackoverflow SAS community. Vectorized solution to finding first element in a row meeting criterion

WPS/Proc R solution

github (do not copy and paste from readme.md us the .sas file)
https://tinyurl.com/y8mqtt98
https://github.com/rogerjdeangelis/utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion

https://tinyurl.com/yacj7kxv
https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Vectorized-solution-to-finding-first-element-in-a-row-meeting/m-p/464858



INPUT
=====
                             | WANT |
 WORK.HAVE total obs=3       |      |
                             |      |  column index for *first* occurance < .1 in each row
     V1      V2      V3      |      |  0 if no element < .1
                             |      |
    0.20    0.30    0.05     |  3   |  V3 first col less than .1
    0.01    0.01    0.01     |  1   |  V1 first col less than .1
    0.20    0.30    0.50     |  0   |  no columns so return 0


EXAMPLE OUTPUT

   WORK.WANT total obs=3

   Obs    WANT

    1       3
    2       1
    3       0


PROCESS ( Working code)
=======================

  zroOne<-(have<.1)*1;   * binary matrix;

  * find the first 1 and use rowMax to set value to 0;
  want<-max.col(zroOne,"first")*rowMaxs(zroOne);


OUTPUT
======

options validvarname=upcase;
libname sd1 "d:/sd1";
data sd1.have;
 input v1 v2 v3;
cards4;
0.20 0.30 0.05
0.01 0.01 0.01
0.20 0.30 0.50
;;;;
run;quit;

*          _       _   _
 ___  ___ | |_   _| |_(_) ___  _ __
/ __|/ _ \| | | | | __| |/ _ \| '_ \
\__ \ (_) | | |_| | |_| | (_) | | | |
|___/\___/|_|\__,_|\__|_|\___/|_| |_|

;

%utl_submit_wps64('
libname sd1 "d:/sd1";
options set=R_HOME "C:/Program Files/R/R-3.3.2";
libname wrk  sas7bdat "%sysfunc(pathname(work))";
proc r;
submit;
source("C:/Program Files/R/R-3.3.2/etc/Rprofile.site", echo=T);
library(matrixStats);
library(haven);
have<-as.matrix(read_sas("d:/sd1/have.sas7bdat"));
have;
zroOne<-(have<.1)*1;
want<-max.col(zroOne,"first")*rowMaxs(zroOne);
want;
endsubmit;
import r=want data=wrk.want;
run;quit;
');

proc print data=want;
run;quit;

utl_vectorized_solution_to_finding_first_element_in_a_row_meeting_criterion's People

Contributors

rogerjdeangelis avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.