BookmarkSubscribeRSS Feed
ss1345
Calcite | Level 5

My data is not uploading properly in SAS and the data is not displaying in the table. Please help!

salary data.jpegtable.jpeg

10 REPLIES 10
Tom
Super User Tom
Super User

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}.

ss1345
Calcite | Level 5
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 DATA salaries;
72 INFILE"/home/u41426832/sasuser.v94/Salaries.txt";
73 INPUT employeeID rank discipline sex $;
74 *Dollar sign means were going to treat Carb_Barrels as categorical variables*;
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: 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
NOTE: Invalid data for rank in line 2 6-9.
NOTE: Invalid data for discipline in line 2 13-13.
2 2 Prof B 20 16 Male 173200 34
employeeID=2 rank=. discipline=. sex=20 _ERROR_=1 _N_=2
NOTE: Invalid data for rank in line 3 6-13.
NOTE: Invalid data for discipline in line 3 17-17.
3 3 AsstProf B 4 3 Male 79750 35
employeeID=3 rank=. discipline=. sex=4 _ERROR_=1 _N_=3
NOTE: Invalid data for rank in line 4 6-9.
NOTE: Invalid data for discipline in line 4 13-13.
4 4 Prof B 45 39 Male 115000 34
employeeID=4 rank=. discipline=. sex=45 _ERROR_=1 _N_=4
NOTE: Invalid data for rank in line 5 6-9.
NOTE: Invalid data for discipline in line 5 13-13.
5 5 Prof B 40 41 Male 141500 34
employeeID=5 rank=. discipline=. sex=40 _ERROR_=1 _N_=5
NOTE: Invalid data for rank in line 6 6-14.
NOTE: Invalid data for discipline in line 6 18-18.
6 6 AssocProf B 6 6 Male 97000 36
employeeID=6 rank=. discipline=. sex=6 _ERROR_=1 _N_=6
NOTE: Invalid data for rank in line 7 6-9.
NOTE: Invalid data for discipline in line 7 13-13.
7 7 Prof B 30 23 Male 175000 34
employeeID=7 rank=. discipline=. sex=30 _ERROR_=1 _N_=7
NOTE: Invalid data for rank in line 8 6-9.
NOTE: Invalid data for discipline in line 8 13-13.
8 8 Prof B 45 45 Male 147765 34
employeeID=8 rank=. discipline=. sex=45 _ERROR_=1 _N_=8
NOTE: Invalid data for rank in line 9 6-9.
NOTE: Invalid data for discipline in line 9 13-13.
9 9 Prof B 21 20 Male 119250 34
employeeID=9 rank=. discipline=. sex=21 _ERROR_=1 _N_=9
NOTE: Invalid data for rank in line 10 7-10.
NOTE: Invalid data for discipline in line 10 14-14.
10 10 Prof B 18 18 Female 129000 37
employeeID=10 rank=. discipline=. sex=18 _ERROR_=1 _N_=10
NOTE: Invalid data for rank in line 11 7-15.
NOTE: Invalid data for discipline in line 11 19-19.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
11 11 AssocProf B 12 8 Male 119800 39
employeeID=11 rank=. discipline=. sex=12 _ERROR_=1 _N_=11
NOTE: Invalid data for rank in line 12 7-14.
NOTE: Invalid data for discipline in line 12 18-18.
12 12 AsstProf B 7 2 Male 79800 36
employeeID=12 rank=. discipline=. sex=7 _ERROR_=1 _N_=12
NOTE: Invalid data for rank in line 13 7-14.
NOTE: Invalid data for discipline in line 13 18-18.
13 13 AsstProf B 1 1 Male 77700 36
employeeID=13 rank=. discipline=. sex=1 _ERROR_=1 _N_=13
NOTE: Invalid data for rank in line 14 7-14.
NOTE: Invalid data for discipline in line 14 18-18.
14 14 AsstProf B 2 0 Male 78000 36
employeeID=14 rank=. discipline=. sex=2 _ERROR_=1 _N_=14
NOTE: Invalid data for rank in line 15 7-10.
NOTE: Invalid data for discipline in line 15 14-14.
15 15 Prof B 20 18 Male 104800 35
employeeID=15 rank=. discipline=. sex=20 _ERROR_=1 _N_=15
NOTE: Invalid data for rank in line 16 7-10.
NOTE: Invalid data for discipline in line 16 14-14.
16 16 Prof B 12 3 Male 117150 34
employeeID=16 rank=. discipline=. sex=12 _ERROR_=1 _N_=16
NOTE: Invalid data for rank in line 17 7-10.
NOTE: Invalid data for discipline in line 17 14-14.
17 17 Prof B 19 20 Male 101000 35
employeeID=17 rank=. discipline=. sex=19 _ERROR_=1 _N_=17
NOTE: Invalid data for rank in line 18 7-10.
NOTE: Invalid data for discipline in line 18 14-14.
18 18 Prof A 38 34 Male 103450 35
employeeID=18 rank=. discipline=. sex=38 _ERROR_=1 _N_=18
NOTE: Invalid data for rank in line 19 7-10.
NOTE: Invalid data for discipline in line 19 14-14.
19 19 Prof A 37 23 Male 124750 35
employeeID=19 rank=. discipline=. sex=37 _ERROR_=1 _N_=19
NOTE: Invalid data for rank in line 20 7-10.
NOTE: Invalid data for discipline in line 20 14-14.
WARNING: Limit set by ERRORS= option reached. Further errors of this type will not be printed.
20 20 Prof A 39 36 Female 137000 37
employeeID=20 rank=. discipline=. sex=39 _ERROR_=1 _N_=20
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.18 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 772.84k
OS Memory 28840.00k
Timestamp 08/31/2019 07:55:14 PM
Step Count 37 Switch Count 2
Page Faults 0
Page Reclaims 163
Page Swaps 0
Voluntary Context Switches 17
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
 
 
76
77
78
79 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
90
 
Tom
Super User Tom
Super User

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?

ss1345
Calcite | Level 5

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.

Tom
Super User Tom
Super User

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.

ss1345
Calcite | Level 5

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

 

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.00 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 770.56k
OS Memory 29608.00k
Timestamp 08/31/2019 09:11:28 PM
Step Count 148 Switch Count 2
Page Faults 0
Page Reclaims 150
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
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.43 seconds
user cpu time 0.43 seconds
system cpu time 0.00 seconds
memory 2367.09k
OS Memory 30120.00k
Timestamp 08/31/2019 09:11:28 PM
Step Count 149 Switch Count 0
Page Faults 0
Page Reclaims 151
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 1136.25k
OS Memory 30892.00k
Timestamp 08/31/2019 09:11:28 PM
Step Count 150 Switch Count 2
Page Faults 0
Page Reclaims 225
Page Swaps 0
Voluntary Context Switches 14
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 491.96k
OS Memory 30632.00k
Timestamp 08/31/2019 09:11:28 PM
Step Count 151 Switch Count 0
Page Faults 0
Page Reclaims 49
Page Swaps 0
Voluntary Context Switches 0
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 527.96k
OS Memory 30632.00k
Timestamp 08/31/2019 09:11:28 PM
Step Count 152 Switch Count 0
Page Faults 0
Page Reclaims 50
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
 
User: u41426832
Messages: 16
 
This is also my log now and I am unsure where I am going wrong
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Tom
Super User Tom
Super User

You still seem to be having trouble with the forum editor. Make sure to use the Insert Code button pasting log lines.

image.png

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?

ss1345
Calcite | Level 5
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        
Tom
Super User Tom
Super User

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.

ss1345
Calcite | Level 5

I fixed it! Thank you so much for your help!

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 1092 views
  • 0 likes
  • 2 in conversation