Guest User

Untitled

a guest
Oct 16th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SAS 3.72 KB | None | 0 0
  1. Data Temp;
  2. infile datalines delimiter=','; /*infile modifies the input statement, delimiter*/
  3. input gender id race ses schtyp prgtype $ read write math science socst ;
  4. datalines;
  5. 0,70,4,1,1,"general",57,52,41,47,57
  6. 1,121,4,2,1,"vocati",68,59,53,63,61
  7. 0,86,4,3,1,"general",44,33,54,58,31
  8. 0,141,4,3,1,"vocati",63,44,47,53,56
  9. 0,172,4,2,1,"academic",47,52,57,53,61
  10. 0,113,4,2,1,"academic",44,52,51,63,61
  11. 0,50,3,2,1,"general",50,59,42,53,61
  12. 0,11,1,2,1,"academic",34,46,45,39,36
  13. 0,84,4,2,1,"general",63,57,54,,51
  14. 0,48,3,2,1,"academic",57,55,52,50,51
  15. 0,75,4,2,1,"vocati",60,46,51,53,61
  16. 0,60,5,2,1,"academic",57,65,51,63,61
  17. 0,95,4,3,1,"academic",73,60,71,61,71
  18. ;
  19. run;
  20.  
  21. proc print data=temp;
  22. run;
  23.  
  24.  
  25. Data Temp2;
  26. infile datalines delimiter=',' missover; /*infile modifies the input statement, delimiter specifies the barrier between
  27. data variables, missover strops reading in the lines when missing data is encountered*/
  28. input gender id race ses schtyp prgtype $ read write math science socst ;
  29. datalines;
  30. 0,70,4,1,1,"general",57,52,41,47,57
  31. 1,121,4,2,1,"vocati",68,59,53,63,61
  32. 0,86,4,3,1,"general",44,33,54,58,31
  33. 0,141,4,3,1,"vocati",63,44,47,53,56
  34. 0,172,4,2,1,"academic",47,52,57,53,61
  35. 0,113,4,2,1,"academic",44,52,51,63,61
  36. 0,50,3,2,1,"general",50,59,42,53,61
  37. 0,11,1,2,1,"academic",34,46,45,39,36
  38. 0,84,4,2,1,"general",63,57,54,,51
  39. 0,48,3,2,1,"academic",57,55,52,50,51
  40. 0,75,4,2,1,"vocati",60,46,51,53,61
  41. 0,60,5,2,1,"academic",57,65,51,63,61
  42. 0,95,4,3,1,"academic",73,60,71,61,71
  43. ;
  44. run;
  45.  
  46. proc print data=Temp2;
  47. run;
  48.  
  49. Data Temp3;
  50. infile datalines delimiter=',' dsd; /*DSD accounts for missing values when two consecutives
  51.                                         delimiters are found, also assumes "" things are strings and does not shorten them*/
  52. input gender id race ses schtyp prgtype $ read write math science socst ;
  53. datalines;
  54. 0,70,4,1,1,"general",57,52,41,47,57
  55. 1,121,4,2,1,"vocati",68,59,53,63,61
  56. 0,86,4,3,1,"general",44,33,54,58,31
  57. 0,141,4,3,1,"vocati",63,44,47,53,56
  58. 0,172,4,2,1,"academic",47,52,57,53,61
  59. 0,113,4,2,1,"academic",44,52,51,63,61
  60. 0,50,3,2,1,"general",50,59,42,53,61
  61. 0,11,1,2,1,"academic",34,46,45,39,36
  62. 0,84,4,2,1,"general",63,57,54,,51
  63. 0,48,3,2,1,"academic",57,55,52,50,51
  64. 0,75,4,2,1,"vocati",60,46,51,53,61
  65. 0,60,5,2,1,"academic",57,65,51,63,61
  66. 0,95,4,3,1,"academic",73,60,71,61,71
  67. ;
  68. run;
  69.  
  70. proc print data=Temp3;
  71. run;
  72.  
  73. data pilotdata;
  74.      infile datalines missover;
  75.      input EmployeeID  $  
  76.            FirstName   $  
  77.            LastName    $
  78.            JobCode     $
  79.            Salary        
  80.            Category    $;
  81.      Datalines;
  82. E01046  DAVID        CHAPMAN        PILOT1  72660 DOM
  83. E02659  CLIFTON      WILDER         PILOT1  53630 DOM
  84. E04732  CHRISTIAN    EDMINSTON      PILOT1  76120 DOM
  85. E03389  LOUISE       STAINES        PILOT1  74390 DOM
  86. E01702  ROBERTA      CHADWICK       PILOT1  62280 DOM
  87. E01642  NANCY        MCELROY        PILOT2  78260 DOM
  88. E03875  PAUL         GLENNON        PILOT2  74620 DOM
  89. E03739  WILLIAM      MCKENZIE       PILOT2  74620 DOM
  90. E03637  HERMAN       VELAZQUEZ      PILOT2  79460 INT
  91. E04481  SANDRA       SANFORD        PILOT2  74820 DOM
  92. E03728  MELANIE      MASON          PILOT4 116510
  93. E03892  THEODORE     LEE            PILOT3 112690 INT
  94. E02417  JANICE       CASEY          PILOT3 124150 INT
  95. E02757  THOMAS       KRELLWITZ      PILOT3 122240 INT
  96. ;
  97. run;
  98.  
  99. proc print data=pilotdata;
  100.      var EmployeeID FirstName LastName JobCode Category;
  101. run;
  102.  
  103. Data Pilot1; /*set is bringing in existing data ex. here is pilotdata*/
  104.     Set pilotdata;
  105.     /* Only uses data that have DOM, and the salary has limits*/
  106.     If Category = 'DOM';
  107.     If 65000 <= Salary <= 75000;
  108. Run;
  109.  
  110. Proc Print data=Pilot1;
  111. Run;
  112.  
  113. Proc Print data=pilotdata;
  114.     where Category = 'DOM';
  115.     where 65000 <= Salary <= 75000;
  116. Run;
Add Comment
Please, Sign In to add comment