DATA Step, Macro, Functions and more

re: creating new variables

Accepted Solution Solved
Reply
Regular Contributor
Posts: 248
Accepted Solution

re: creating new variables

Hi.....I have enrollment data that I am trying to create separate reports, one in the Fall and the other in the Winter. Each report is based on the academic year and the term number that the student was enrolled in. The field "Term" consist of the academic year and term number that the student was enrolled. The Fall report is to consist of Term 1 of the current academic year and Terms 2 & 3 of the previous academic year. The Winter report is to consist of Terms 1 & 2 of the current academic year. Any suggestion on to obtain this....thanks

 

Have:

Student ID Term
10010 15-16 TRM 2
10010 15-16 TRM 3
10010 16-17 TRM 1
10010 16-17 TRM 2
10010 16-17 TRM 3
10032 16-17 TRM 2
10032 16-17 TRM 3
10032 17-18 TRM 1

 

 

Want:

Student ID Term Fall Winter
10010 15-16 TRM 2 16-17 15-16
10010 15-16 TRM 3 16-17  
10010 16-17 TRM 1 16-17 16-17
10010 16-17 TRM 2 17-18 16-17
10010 16-17 TRM 3 17-18  
10032 16-17 TRM 2 17-18 16-17
10032 16-17 TRM 3 17-18  
10032 17-18 TRM 1 17-18 17-18

Accepted Solutions
Solution
‎12-04-2017 07:46 PM
Trusted Advisor
Posts: 1,848

Re: re: creating new variables

You can calcolate term_no and season from term using function scan:

 

length term_no $1   fall winter season $5;
term_no = scan(term, -1);
season = scan(term, 1);

 

All you need now is to assign values to fall and to winter according to above values.

View solution in original post


All Replies
Solution
‎12-04-2017 07:46 PM
Trusted Advisor
Posts: 1,848

Re: re: creating new variables

You can calcolate term_no and season from term using function scan:

 

length term_no $1   fall winter season $5;
term_no = scan(term, -1);
season = scan(term, 1);

 

All you need now is to assign values to fall and to winter according to above values.

Regular Contributor
Posts: 248

Re: re: creating new variables

Hi Shmuel,

 

I followed your suggestion and it worked....thanks for your help.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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