BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tekish
Quartz | Level 8

Dear Experts,

 

I have a large dataset with so many records, I want to fill the missing values. I to create new two variables, "Principal" and "Vice".

 

data school;

length schoolname $20 teachername $50;

input schoolname 1-21 subject$ 23 ID 26-27 teachername 32-54 Qtype;

cards;

holmes middle school M -1 Doris Wilson 5

holmes middle school M 0 Amy Smith 7

holmes middle school R 1 Mrs. A. T. Whitecotton 6

holmes middle school M 2 Geraldine Carpenter 6

holmes middle school R 3 Jennie Crigler 6

holmes middle school M 4 Lida Gray Gibbs 6

holmes middle school M 5 Irene Ball 6

holmes middle school R 6 Wynona James 6

holmes middle school M 7 Moneaka Elam 8

holmes middle school M 8 Doris Stephens 8

holmes middle school G 9 Catherine Clark 8

holmes middle school M 10 Elma Kemp 8

holmes middle school M 11 Lois Pagett 8

holmes middle school M 12 Ruby Partin 8

holmes middle school H 13 Fances Nugent 8

;

run;

proc sort data=school out=school;

by schoolname ID Qtype;

run;

 

data school1;

set school end=eof;

by schoolname ID Qtype;

if ID=-1 and Qtype=5 then principal=TeacherName;

if ID=0 and Qtype=7 then Vice=TeacherName;

run;

 

the expected output.

 

schoolnameteachernamesubjectIDQtypeprincipalVice
holmes middle schoolDoris WilsonM-15Doris WilsonAmy Smith
holmes middle schoolAmy SmithM07Doris WilsonAmy Smith
holmes middle schoolMrs. A. T. WhitecottonR16Doris WilsonAmy Smith
holmes middle schoolKemp ElmaM18Doris WilsonAmy Smith
holmes middle schoolPagett LoisM18Doris WilsonAmy Smith
holmes middle schoolPartin RubyM18Doris WilsonAmy Smith
holmes middle schoolNugent FancesH18Doris WilsonAmy Smith
holmes middle schoolGeraldine CarpenterM26Doris WilsonAmy Smith
holmes middle schoolCrigler JennieR36Doris WilsonAmy Smith
holmes middle schoolLida Gray GibbsM46Doris WilsonAmy Smith
holmes middle schoolBall IreneM56Doris WilsonAmy Smith
holmes middle schoolJames WynonaR66Doris WilsonAmy Smith
holmes middle schoolElam MoneakaM78Doris WilsonAmy Smith
holmes middle schoolStephens DorisM88Doris WilsonAmy Smith
holmes middle schoolClark CatherineG98Doris WilsonAmy Smith
river middle schoolIone RansdellM-15Ione RansdellAElgelina Atterbury
river middle schoolAElgelina AtterburyM07Ione RansdellAElgelina Atterbury
river middle schoolMWynona JamesR16Ione RansdellAElgelina Atterbury
river middle schoolHopson NannieM18Ione RansdellAElgelina Atterbury
river middle schoolLutie CaldwellM18Ione RansdellAElgelina Atterbury
river middle schoolMaydee MalloryM18Ione RansdellAElgelina Atterbury
river middle schoolLois PagettH18Ione RansdellAElgelina Atterbury
river middle schoolAbigail MarlowM26Ione RansdellAElgelina Atterbury
river middle schoolJennie CriglerR36Ione RansdellAElgelina Atterbury
river middle schoolLida Gray GibbsM46Ione RansdellAElgelina Atterbury
river middle schoolBall IreneM56Ione RansdellAElgelina Atterbury
river middle schoolJames WynonaR66Ione RansdellAElgelina Atterbury
river middle schoolElam MoneakaM78Ione RansdellAElgelina Atterbury
river middle schoolCarpenter ImogeneM88Ione RansdellAElgelina Atterbury
river middle schoolFlowers MarthaG98Ione RansdellAElgelina Atterbury
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
RETAIN PRINCIPAL VICE;

View solution in original post

2 REPLIES 2
Reeza
Super User
RETAIN PRINCIPAL VICE;
tekish
Quartz | Level 8

Reeza,

 

Thanks.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 820 views
  • 0 likes
  • 2 in conversation