lalit chaudhary


{ City } new delhi
< Country > india
* Profession *
User No # 119326
Total Questions Posted # 0
Total Answers Posted # 3

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 2
Users Marked my Answers as Wrong # 0
Questions / { lalit chaudhary }
Questions Answers Category Views Company eMail




Answers / { lalit chaudhary }

Question { 2346 }

data task;
input id date date9. visit;
cards;
101 01jan2015 1
101 02jan2015 2
101 06jan2015 3
102 04jan2015 1
102 07jan2015 2
102 12jan2015 3
103 06jan2015 1
103 13jan2015 2
;
run;
write a program to find out missing dates between visits by each subject.


Answer

data task;
input id date date9. visit ;
cards;
101 01jan2015 1
101 02jan2015 2
101 06jan2015 3
102 04jan2015 1
102 07jan2015 2
102 12jan2015 3
103 06jan2015 1
103 13jan2015 2
;
run;

Answer

data task1;
set task;
by id;
date1=lag(date);
if first.id ne 1 then x=date-date1;
run;

proc print; run;

proc transpose data = task out = b;
var date;
by id;
run;

data new;
set b;
x=col2-col1;
y=col3-col2;
run;

proc print; run;

Is This Answer Correct ?    0 Yes 0 No

Question { 2384 }

Hi im new to sas. I have a file with some charecter variables and some numeric variables
now i want to load charecter variables into one datastep and numeric variables into another data step pls let me know
Thanks


Answer

data a;
infile "C:Documents and SettingssasadmDesktopSASMacro est1.txt" firstobs=2;
input num1 num2 num3 c1$ c2$ num4 c3$;
run;

data b;
set a;
keep _numeric_;
run;

data c;
set a;
keep _character_;
run;

Is This Answer Correct ?    1 Yes 0 No


Question { HSBC, 2437 }

Below is the table.









Required to be output should be the highest number of each student_id.
Example.
Student_id Subject Marks
1 Hindi 86
2 Hindi 70
3 English 80
.

Calculate sum and average marks for each group of student_id
Example.
Student_id Subject Marks Total Marks Average
1 English 40 181 60.33333
2 English 67 196 65.33333
3 English 80 160 53.33333

PLEASE PROVIDE THE CODE OF ABOVE PROBLEMS


Answer

data a;
input id sub$ marks;
cards;
1 Hindi 86
2 Hindi 70
3 Hindi 80
1 English 80
2 English 34
3 English 39
1 Maths 28
2 Maths 45
3 Maths 12
;
run;

proc sort data = a out=b;
by id descending marks;
run;

data c (drop=total_marks) d;
set b;
by id descending marks;
if first.id then output c;
if first.id then total_marks=marks;
else total_marks+marks;
if last.id then output d;
run;

proc print; run;

proc means data = a mean max sum;
class id;
var marks;
output out=df;
run;

proc means data = a noprint nway;
class id;
var marks;
output out=df sum= mean= max= /autoname;
run;

proc print; run;

Is This Answer Correct ?    1 Yes 0 No