My data is not uploading properly in SAS and the data is not displaying in the table. Please help!
Show the log from running the first step.
Do NOT post photographs of your log. Instead select the actual text characters and paste them into the window that opens when you click on the Insert Code icon in this forums editor screen. The icon on the menu looks like {i}.
You didn't use the Insert Code feature which is why your post is unreadable.
I will try to fix it so we can look at it. Based on the column numbers in the notes your actual error message probably looks more like this:
NOTE: Invalid data for rank in line 1 6-9. NOTE: Invalid data for discipline in line 1 13-13. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 1 1 Prof B 19 18 Male 139750 34 employeeID=1 rank=. discipline=. sex=19 _ERROR_=1 _N_=1
Why did you try to read values like 'PROF' and 'B' into numeric variables?
My professor gave us a txt file to upload into SAS and told us to "Instruct SAS to treat employeeID, rank, discipline, and sex as character" and then taught us to use the input tool for that.
But your code is only telling SAS that SEX should be read as character.
DATA salaries;
INFILE"/home/u41426832/sasuser.v94/Salaries.txt";
INPUT employeeID rank discipline sex $;
*Dollar sign means were going to treat Carb_Barrels as categorical variables*;
RUN;
Didn't your instructor teach you how to actually DEFINE the variables, instead of forcing SAS to guess what you meant based on how you first use them in other statements like INPUT?
DATA salaries;
INFILE"/home/u41426832/sasuser.v94/Salaries.txt";
LENGTH employeeID $20 rank $8 discipline $10 sex $5 ;
INPUT employeeID rank discipline sex ;
RUN;
Also from the lines in your log it looks like the file has 7 columns, not 4.
no we just typed them in class 😞
DATA salaries;
INFILE"/home/u41426832/sasuser.v94/Salaries.txt";
LENGTH employeeID $20 rank $8 discipline $10 sex $5 ;
INPUT employeeID rank discipline sex ;
RUN;
proc print data=salaries;
run;
PROC FREQ data=salaries;
Table rank;
run;
PROC MEANS DATA=salaries;
CLASS sex rank;
VAR salary;
RUN;
proc univariate data=salaries;
var employeeID $20 rank $8 discipline $10 sex $5;
histogram employeeID $20 rank $8 discipline $10 sex $5;
run;
I've written this now as our full project and some works and some do not
You still seem to be having trouble with the forum editor. Make sure to use the Insert Code button pasting log lines.
So how do expect to do analysis of a variable named SALARY if you did not create that variable in the first step?
Perhaps that is one of the extra values?
DATA salaries; INFILE"/home/u41426832/sasuser.v94/Salaries.txt"; LENGTH employeeID $20 rank $8 discipline $10 sex $5 ; INPUT employeeID rank discipline sex ; RUN; proc print data=salaries; run; PROC FREQ data=salaries; Table rank; run; PROC MEANS DATA=salaries; CLASS sex rank; VAR salary; RUN; proc univariate data=salaries; var employeeID $20 rank $8 discipline $10 sex $5; histogram employeeID $20 rank $8 discipline $10 sex $5; run;
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 70 71 DATA salaries; 72 INFILE"/home/u41426832/sasuser.v94/Salaries.txt"; 73 LENGTH employeeID $20 rank $8 discipline $10 sex $5 ; 74 INPUT employeeID rank discipline sex ; 75 RUN; NOTE: The infile "/home/u41426832/sasuser.v94/Salaries.txt" is: Filename=/home/u41426832/sasuser.v94/Salaries.txt, Owner Name=u41426832,Group Name=oda, Access Permission=-rw-r--r--, Last Modified=31Aug2019:14:05:17, File Size (bytes)=14886 NOTE: 397 records were read from the infile "/home/u41426832/sasuser.v94/Salaries.txt". The minimum record length was 34. The maximum record length was 43. NOTE: The data set WORK.SALARIES has 397 observations and 4 variables. NOTE: DATA statement used (Total process time): real time 0.17 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 764.75k OS Memory 27560.00k Timestamp 08/31/2019 10:15:25 PM Step Count 24 Switch Count 2 Page Faults 0 Page Reclaims 186 Page Swaps 0 Voluntary Context Switches 17 Involuntary Context Switches 0 Block Input Operations 32 Block Output Operations 264 76 77 proc print data=salaries; 78 run; NOTE: There were 397 observations read from the data set WORK.SALARIES. NOTE: PROCEDURE PRINT used (Total process time): real time 0.42 seconds user cpu time 0.42 seconds system cpu time 0.00 seconds memory 2488.09k OS Memory 29352.00k Timestamp 08/31/2019 10:15:25 PM Step Count 25 Switch Count 0 Page Faults 0 Page Reclaims 829 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 1 Block Input Operations 0 Block Output Operations 192 79 80 PROC FREQ data=salaries; 81 Table rank; 82 run; NOTE: There were 397 observations read from the data set WORK.SALARIES. NOTE: PROCEDURE FREQ used (Total process time): real time 0.01 seconds user cpu time 0.02 seconds system cpu time 0.00 seconds memory 1177.34k OS Memory 30124.00k Timestamp 08/31/2019 10:15:25 PM Step Count 26 Switch Count 2 Page Faults 0 Page Reclaims 375 Page Swaps 0 Voluntary Context Switches 11 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 264 83 84 PROC MEANS DATA=salaries; 85 CLASS sex rank; 86 VAR salary; ERROR: Variable SALARY not found. 87 RUN; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE MEANS used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 494.09k OS Memory 29864.00k Timestamp 08/31/2019 10:15:25 PM Step Count 27 Switch Count 0 Page Faults 0 Page Reclaims 105 Page Swaps 0 Voluntary Context Switches 1 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 88 89 proc univariate data=salaries; 90 var employeeID $20 rank $8 discipline $10 sex $5; _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored. 91 histogram employeeID $20 rank $8 discipline $10 sex $5; _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored. 92 run; NOTE: The SAS System stopped processing this step because of errors. NOTE: PROCEDURE UNIVARIATE used (Total process time): real time 0.00 seconds user cpu time 0.00 seconds system cpu time 0.00 seconds memory 502.40k OS Memory 29864.00k Timestamp 08/31/2019 10:15:25 PM Step Count 28 Switch Count 0 Page Faults 0 Page Reclaims 104 Page Swaps 0 Voluntary Context Switches 0 Involuntary Context Switches 0 Block Input Operations 0 Block Output Operations 0 93 94 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK; 105
So you have two errors.
84 PROC MEANS DATA=salaries; 85 CLASS sex rank; 86 VAR salary; ERROR: Variable SALARY not found. 87 RUN;
You are asking PROC MEANS to analyze the variable SALARY but you did not create a variable with that name in your first data step. Does that data file have such a variable? Where is it on the line? Is it after the last variable you are reading with your INPUT statement?
89 proc univariate data=salaries; 90 var employeeID $20 rank $8 discipline $10 sex $5; _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored. 91 histogram employeeID $20 rank $8 discipline $10 sex $5; _ 22 76 ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, _ALL_, _CHARACTER_, _CHAR_, _NUMERIC_. ERROR 76-322: Syntax error, statement will be ignored. 92 run;
Why does the VAR statement in your PROC UNIVARIATE step include those length values?
Also how is PROC UNIVARIATE going analyze character variables like RANK?
You need to give it NUMERIC variables.
PS You should see if you can figure out how to turn off the FULLSTIMER option. It is adding 12 extra lines to your SAS log for every step you run of information that is probably of absolutely no use to you now. They just make the logs longer and harder for you to read. You can always turn it back on if there is some issue where you want to see that level of detail.
I fixed it! Thank you so much for your help!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: