I have a dataset like
STUDENTNAME DIVISION
A firstdiv
B secdiv
C thirdiv
D firstdiv
F thirdiv
I have to create a format like
proc format $division;
value 'firstdiv' =1
'secdiv'=2
'thirdiv'=3
'all'= '1','2','3','all';
Kindly help me how to create format
Regards,
Ashwini
Please ignore the above dataset .The dataset is like
Studentname division
A 1
B 2
c 3
D 2
F 3
I have to create a format like
proc format $division;
value 'firstdiv' =1
'secdiv'=2
'thirdiv'=3
'all'= '1','2','3','all';
Kindly help me how to create format
Regards,
Ashwini
Some code like below and as documented under http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473491.htm could do.
data have;
infile datalines dsd;
input Studentname $ division;
datalines;
A,1
B,2
c,3
D,2
F,3
;
run;
data ctrl / view=ctrl;
retain fmtname 'division' type 'c';
set have(rename=(Studentname=Start)) end=last;
label=put(Division,1.);
output;
if last then do;
hlo='O';
label='?';
output;
end;
run;
proc format lib=work cntlin=ctrl;
run;
data _null_;
do StudentName='A','B','X','F';
put 'Student ' StudentName 'is in Division ' StudentName $division.;
end;
run;
I'm confused! What are you trying to do? Your proc format is slightly reversed from your data .. the data values should be on the left and their meanings on the right, the format name should come after the word value, from your data and subject line you are trying to create a numeric format but you specified a character format, and it appears like you actually want a multilabel format. Are you looking to accomplish something like?:
data have;
input Studentname $ division score;
cards;
A 1 13
B 2 9
c 3 6
D 2 12
F 3 18
;
proc format;
value division (multilabel)
1='firstdiv'
2='secdiv'
3='thirdiv'
1,2,3='all'
;
run;
proc means data=have mean nonobs;
class division /mlf order=fmt;
var score;
format division division.;
run;
May be you are looking:
proc format $division;
value 'firstdiv' ='1'
'secdiv'='2'
'thirdiv'='3'
'all'= '1 , 2, 3, all';
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.
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.