Data Subsetting - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Data Subsetting

Description:

merge master (in=alaska) test (in=ohio); by id; if alaska and ... proc print data=update1; title Update1'; proc print data=newmastr; title New Master'; run; ... – PowerPoint PPT presentation

Number of Views:28
Avg rating:3.0/5.0
Slides: 14
Provided by: mickey9
Category:

less

Transcript and Presenter's Notes

Title: Data Subsetting


1
Chapter 14
2
Data Subsetting
  • data all
  • input gender age
  • datalines
  • male 45
  • female 22
  • female 41
  • male 24
  • female 33
  • male 28
  • data women
  • set all
  • if gender "female"
  • proc print datawomen
  • run

3
  • data women
  • set all
  • if gender "female" and age lt 40
  • proc print datawomen
  • run

4
WHERE
  • data all
  • input gender age group
  • datalines
  • male 45 a
  • female 22 b
  • female 41 c
  • male 24 a
  • female 33 b
  • male 28 c
  • proc ttest dataall
  • where group'a' OR group'c'
  • class group
  • var age
  • run

5
Combining similar data sets
  • data men
  • input gender age
  • datalines
  • male 45
  • male 24
  • data women
  • input gender age
  • datalines
  • female 22
  • female 41
  • data all
  • set men women
  • proc print dataall
  • run

6
Combining different datasets
  • data master
  • input ID exam1
  • datalines
  • 3491 77
  • 1012 94
  • 1022 88
  • data test
  • input ID exam2
  • datalines
  • 1012 83
  • 3491 89
  • proc sort datamaster
  • by id
  • proc sort datatest
  • by id
  • data all
  • merge master test
  • by id
  • proc print dataall
  • run

7
(No Transcript)
8
  • data all
  • merge master test (inanyword)
  • by id
  • if anyword
  • run

9
  • proc sort datamaster
  • by id
  • proc sort datatest
  • by id
  • data both
  • merge master (inalaska)
  • test (inohio)
  • by id
  • if alaska and ohio
  • run
  • proc print databoth
  • run
  • data master
  • input ID exam1
  • datalines
  • 1012 94
  • 1022 88
  • 4010 64
  • data test
  • input ID exam2
  • datalines
  • 1012 83
  • 1022 91
  • 3491 89

10
(No Transcript)
11
Updating a Master Data Set
  • data master
  • input ID lastvist mmddyy10.
  • datalines
  • 1012 10/21/1998
  • 1143 11/11/2002
  • 4010 08/06/2001
  • data update1
  • input ID lastvist mmddyy10.
  • datalines
  • 1012 09/05/2003
  • 1143 12/24/2003
  • 3491 12/22/2003

12
  • data newmastr
  • update master update1
  • by id
  • proc print datamaster
  • title Master
  • proc print dataupdate1
  • title Update1
  • proc print datanewmastr
  • title New Master
  • run

13
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com