Using this concept, we can report matching observation or non matching observation from required data set. Tracking variable can be created by in option. If tracking variable value is 1 we get matching variable, if tracking variable value is 0 we get non matching variable. /* To report each and every patient SBP information with drug information after taken the treatment*/ Data trt; Infile ‘d:\trt.txt’; Input pid drug $sbp; Cards; Data suc; Infile ‘d:\sucess.txt’; Input pid sbp; Cards; Data fail; Infile ‘d:\fail.txt’; Input pid sbp; Cards; Proc sort data =txt; By eid; Run; Proc sort data =suc; By eid; Run; Proc sort data =fail; By eid; Run; To import the data are txt, suc, fail. Sorting the 3 data sets based on matching variables. /* To update txt with suc*/ Data txt; Update txt suc (in = var); By pid; If var =1 then statue =’sucess’; Run; /* To update txt with fail*/ Data txt; Update txt fail(in = var); By pid; If var =1 then statue =’failure’; If status = ‘ ‘ then Status = ‘change’; Proc print data =txt; Run;
These core tutorials will help you to learn the Tracking variable creations and temporary variable creation in SAS. For an in-depth understanding and practical experience, explore SAS Training Online.
It can be used to replace the data values (from update the data values) manipulating data, delete observations, modifications.
Ex: Data emp; Input eid salary ; Cards; 100 4000 101 8000 ; /* use with set */ Data emp; Set emp; Salary =salary +1000; Run; /* use with modify*/ Data emp; Set emp; Run; Proc print data =emp; Run; Note: Using set statement we can do modifications and these modifications can be stored in new variable and new data set or existed variable and existed data set. Using modify statement we can do modifications and these modifications can be stored in existed data set or existed variable. /*To do modification in one data set to another data set */ Syntax: Modify <master file> <transition file>; By <matching variable>; Ex: Data emp; Input eid salary ; Cards; 100 3000 101 2000 102 4000 ; Data emp1; Input eid bonus; Cards; 100 500 102 1000 101 200; Proc sort data = emp1; By eid; Run; Data emmp; Modify emp emp1; By eid; Salary =salary +bonus; Run; Proc print data =emp; Run;
Ex: Data medi; Input stno drug$ sbp; Cards; 100 col5mg 156 101 col5mg 159 102 col10mg156 103 col10mg145 104 col15mg167 ; Data success; Input stno srate :percent3; Cards; 100 50% 102 40% 100 30% ; Data fail Input stno frate : percent 3.; Cards; 101 20% 104 10% ; Proc sort data =medi; By stno; Run; Proc sort data =success; By stno; Run; Proc sort data =fail; By stno; Run;
Ex: data medi; Modify medi success; By stno; Sbp= sbp * srate; Run; /* To modify medi use with fail*/ Ex: data medi; Modify medi fail; By stno; Sbp= sbp+(sbp *frate); Run; Proc print data =medi; Run;
Ex: Data emp; Input eid salary ; Cards; 100 5000 101 4000 ; Data emp1; Input eid nsal; Cards; 101 7000 100 6000 ; Proc sort data = emp; By eid; Proc sort data = emp1; By eid; Run; Data emp; Modify emp emp1; By eid; Salary =n sal; Run; Proc print data =emp; Run; Case 1: Non matching observation (non obs) occurred in master file we can run the modify statement. Case 2: Non matching observation (non obs) occurred in transition we can’t run the modify statement(modify statement does not have appending capability). Case 3: Non matching variable occurred in master file, we can run the modify statement. Case 4: Non matching variable occurred in transition file, we can’t run the modify statement.
For indepth knowledge on SAS, click on below
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox