We have a raw data set:
Formatted Input
Ram 21 500 Friday,January 1,1960Sita 22 600 Saturday,january 1,1960
Radha 23 700 Sunday,january 1,1960
We have to create a SAS dataset from this raw data set.
output:
Name Age Salary Hire_date
Ram 21 500 01jan1960
Sita 22 600 02jan1960
Radha 23 700 03jan1960
Please write SAS Program to complete this task.
Solution:
data one;
infile 'Filename';
length x $ 10 y $ 10 z $ 10 b $ 15;
input name $ age salary @15 H_D $30.;
keep name age salary Hire_date;
x=scan(H_D,2);
z=scan(H_D,4);
a=strip(x)||strip(z);
b=tranwrd(a,substr(a,1,length(a)-4),substr(a,1,3));
day+1;
k=month(input(b,monyy7.));
Hire_Date=mdy(k,day,z);
format final date9.;
run;
proc print data=one;
run;
Now prepare your Base SAS and
Advance SAS Certification Exams with Online Mock tests: http://exam.sankhyana.com
For training related info kindly mail us at info@sankhyana.com
www.sankhyana.com