SAS SQL or data step: How to select values that begin with different numbers -


maybe title bit blurry, hope understand question.

background: work data university students, , have been given task of calculating grade point averages exams on specific semester subset of predefined students. time span of data 10 years , activity names exams varies across time.

my problem: data has hierarchy structure level of education, semester , activity names. how can use data step/sql on lowest level select values beginning value top hierarchy.

the hierarchy following (for single student):

13109963  1310996300001 131099630000100001 13109963000010000100001 (activities) 13109963000010000100002 (activities) 13109963000010000100003 (activities) 

i have struggled few hours, , appreciate suggestions how proceed on special problem. have been using sas 3 years , have background social sciences.

thank in advance henning

there few options in sas let accomplish task.

here quick example.

 data sample; length  level $60.; input  level $1-60; /*option 1  subset obs based on top hierarchy , select bottom hierarchy  based on length of string */ opt1 = substr(level,1,8)='13109963' , length(level)>23 ; /*option 2  subset obs based on length of string pick lowest level regardless  of top hierarchy (in case return same result) */ opt2 = length(level)>23 ; /* option 3:  if lowest level  hierarchies have '(' can use index function */ opt3 = index(level,'(')>1; /* option 4: using regex think of above suffice*/ cards; 13109963  1310996300001 131099630000100001 13109963000010000100001 (activities) 13109963000010000100002 (activities) 13109963000010000100003 (activities)  ; run; 

you can mix&match of options above select observations required. example: if substr(level,1,8)='13109963'and index(level,'(')>1; return same result.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -