Hi SAS Experts, Trying to Proc Format A1-A5, unfortunately couldn't generate as per described with following errors. What's wrong with the SAS code? Helps..... data a;
infile '/folders/myfolders/a.txt';
input ID $3. Gender $ age salary A1 A2 A3 A4 A5;
run;
proc format;
value $gender 'M' = 'Male'
'F' = 'Female'
' ' = 'Not Entered'
other = 'Miscoded';
value age low-29 = 'Less than 30'
30-50 = '30 to 50'
51-high = '51+';
value A1 1 = 'Strongly Disagree'
2 = 'Disagree'
3 = 'No Opinion'
4 = 'Agree'
5 = 'Strongly Agree';
proc print data=a noobs;
var id gender age salary A1-A5;
format
gender $gender.
age age.
salary dollar11.2
A1 A1.;
run; ID Gender age salary A1 A2 A3 A4 A5 001 Male Less than 30 $28,000.00 1 2 1 2 3 002 Female 51+ $76,123.00 4 5 2 1 1 003 Male 30 to 50 $36,500.00 2 2 2 2 1 004 Female 51+ $128,000.00 5 3 2 2 4 005 Male Less than 30 $23,060.00 3 3 3 4 2 006 Male 51+ $90,000.00 2 3 5 4 3 007 Female 30 to 50 $76,100.00 5 3 4 3 3 Below is the Log Results:- 1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 72 73 data a; 74 infile '/folders/myfolders/a.txt'; 75 input ID $3. Gender $ age salary A1 A2 A3 A4 A5; 76 run; NOTE: The infile '/folders/myfolders/a.txt' is: Filename=/folders/myfolders/a.txt, Owner Name=root,Group Name=vboxsf, Access Permission=-rwxrwx---, Last Modified=29Oct2019:20:16:44, File Size (bytes)=183 NOTE: 8 records were read from the infile '/folders/myfolders/a.txt'. The minimum record length was 0. The maximum record length was 25. NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set WORK.A has 7 observations and 9 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 77 78 proc format; 79 value $gender 'M' = 'Male' 80 'F' = 'Female' 81 ' ' = 'Not Entered' 82 other = 'Miscoded'; NOTE: Format $GENDER is already on the library WORK.FORMATS. NOTE: Format $GENDER has been output. 83 84 value age low-29 = 'Less than 30' 85 30-50 = '30 to 50' 86 51-high = '51+'; NOTE: Format AGE is already on the library WORK.FORMATS. NOTE: Format AGE has been output. 87 88 value A1 '1' = 'Strongly Disagree' ERROR: The format name A1 ends in a number, which is invalid. 89 2 = 'Disagree' 90 3 = 'No Opinion' 91 4 = 'Agree' 92 5 = 'Strongly Agree'; NOTE: The previous statement has been deleted. 93 NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE FORMAT used (Total process time): real time 0.00 seconds cpu time 0.01 seconds 94 proc print data=a noobs; 95 var id gender age salary A1-A5; 96 format 97 gender $gender. 98 age age. 99 salary dollar11.2 100 A1 A1.; 101 102 103 run; NOTE: There were 7 observations read from the data set WORK.A. NOTE: PROCEDURE PRINT used (Total process time): real time 0.09 seconds cpu time 0.09 seconds 104 105 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 117
... View more