BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Stdt
Calcite | Level 5

Dear all,

 

I am new to SAS. I am trying to produce a table from  simple data but the table output is incomplete. In the result viewer, the first column (DATE VAriable) is missing. I have to use the informat command. Can anyone please suggest me why i am not getting the result? Many thanks.

 

DATA PROB_4;
INPUT DATE 1-10 GENDER $ 11 AGE 12-13 SCORE 14-16;
INFORMAT DATE mmddyy10.;
DATALINES;
04/04/2004M15 90
05/12/2004F16 95
07/23/2004M18 88
01/20/2004F17100
;
RUN;
TITLE "Problem 4";
PROC PRINT DATA= PROB_4;
FORMAT DATE mmddyy10.;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Since you specify the columns, the informat is not used.

And since you are reading a string into a numeric variable, missing values are generated.

 

Always look at the LOG. Always!

 

NOTE: Invalid data for DATE in line 30 1-10.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
30 04/04/2004M15 90
DATE=. GENDER=M AGE=15 SCORE=90 _ERROR_=1 _N_=1
NOTE: Invalid data for DATE in line 31 1-10.
31 05/12/2004F16 95
DATE=. GENDER=F AGE=16 SCORE=95 _ERROR_=1 _N_=2
NOTE: Invalid data for DATE in line 32 1-10.
32 07/23/2004M18 88
DATE=. GENDER=M AGE=18 SCORE=88 _ERROR_=1 _N_=3
NOTE: Invalid data for DATE in line 33 1-10.
33 01/20/2004F17100
DATE=. GENDER=F AGE=17 SCORE=100 _ERROR_=1 _N_=4

View solution in original post

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Since you specify the columns, the informat is not used.

And since you are reading a string into a numeric variable, missing values are generated.

 

Always look at the LOG. Always!

 

NOTE: Invalid data for DATE in line 30 1-10.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
30 04/04/2004M15 90
DATE=. GENDER=M AGE=15 SCORE=90 _ERROR_=1 _N_=1
NOTE: Invalid data for DATE in line 31 1-10.
31 05/12/2004F16 95
DATE=. GENDER=F AGE=16 SCORE=95 _ERROR_=1 _N_=2
NOTE: Invalid data for DATE in line 32 1-10.
32 07/23/2004M18 88
DATE=. GENDER=M AGE=18 SCORE=88 _ERROR_=1 _N_=3
NOTE: Invalid data for DATE in line 33 1-10.
33 01/20/2004F17100
DATE=. GENDER=F AGE=17 SCORE=100 _ERROR_=1 _N_=4

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 1 reply
  • 270 views
  • 1 like
  • 2 in conversation