BookmarkSubscribeRSS Feed
SRINIVAS_N
Calcite | Level 5

can any one please help me this 

 

data club;
infile datalines dsd;
input idnumber 1-4
name : $18.
team : $25-30
startwi endwi;
datalines;

1023 DAVID shaw RED 189 155
1049 AMELIA verna YELLOW 145 125
1219 ALAN ranju red 210 192
1246 RAVI shankar YELLOW 177 177
1078 ASHELY valley RED 127 118
1221 JIM rose YELLOW 220 220
;
proc print data=club;
id idnumber;
run;

 

 

output is getting worng 

pls check once 

 

 idnumber name team startwi endwi.121

  ..
9 ALAN ranju red 2192..
13 REPLIES 13
SRINIVAS_N
Calcite | Level 5

can any one please help me this 

 

data club;
infile datalines dsd;
input idnumber 1-4
name : $18.
team : $25-30
startwi endwi;
datalines;

1023 DAVID shaw RED 189 155
1049 AMELIA verna YELLOW 145 125
1219 ALAN ranju red 210 192
1246 RAVI shankar YELLOW 177 177
1078 ASHELY valley RED 127 118
1221 JIM rose YELLOW 220 220
;
proc print data=club;
id idnumber;
run;

 

 

output is getting worng 

pls check once 

 save.png

 

error_prone
Barite | Level 11
Please explain what goes wrong! Posting full log is recommended.
SRINIVAS_N
Calcite | Level 5

pls check the log once 

 

save1.png

Kurt_Bremser
Super User

The log is pure TEXT and can be copy/pasted into a window opened with the {i} button (use that button to preserve the formatting).

Post the complete log of the step (include all step code). If you are reading from an external file, attach that file (at least a few lines that cause the ERRORs) to your post. Or use the same method as mentioned for the log to post the text.

Also see this helper page: https://communities.sas.com/t5/help/faqpage/faq-category-id/posting?nobounce

SRINIVAS_N
Calcite | Level 5
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 70         
 71         
 72         data club;
 73         infile datalines dsd;
 74         input idnumber 1-4
 75         name : $18.
 76         team : $25-30
 77         startwi endwi;
 78         datalines;
 
 NOTE: Invalid data for startwi in line 80 1-33.
 NOTE: Invalid data for endwi in line 81 1-28.
 RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
 
 81  CHAR   .1219 ALAN ranju red 210 192                                                    
     ZONE   03333244442766672766233323332222222222222222222222222222222222222222222222222222
     NUMR   9121901C1E021EA50254021001920000000000000000000000000000000000000000000000000000
 NOTE: Invalid data errors for file CARDS occurred outside the printed range.
 NOTE: Increase available buffer lines with the INFILE n= option.
 idnumber=102 name=3 DAVID shaw RED 1 team=155 startwi=. endwi=. _ERROR_=1 _N_=1
 NOTE: Invalid data for startwi in line 83 1-31.
 NOTE: Invalid data for endwi in line 84 1-29.
 
 84  CHAR   .1221 JIM rose YELLOW 220 220                                                   
     ZONE   03333244427676254444523332333222222222222222222222222222222222222222222222222222
     NUMR   912210A9D02F35095CCF702200220000000000000000000000000000000000000000000000000000
 NOTE: Invalid data errors for file CARDS occurred outside the printed range.
 NOTE: Increase available buffer lines with the INFILE n= option.
 idnumber=124 name=6 RAVI shankar YEL team=W  177 startwi=. endwi=. _ERROR_=1 _N_=2
 NOTE: SAS went to a new line when INPUT statement reached past the end of a line.
 NOTE: The data set WORK.CLUB has 2 observations and 5 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              790.53k
       OS Memory           29352.00k
       Timestamp           03/12/2018 07:39:46 AM
       Step Count                        230  Switch Count  2
       Page Faults                       0
       Page Reclaims                     144
       Page Swaps                        0
       Voluntary Context Switches        10
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           272
       
 85         ;
 
 86         
 86       !  proc print data=club;
 87         id idnumber;
 88         run;
 
 NOTE: There were 2 observations read from the data set WORK.CLUB.
 NOTE: PROCEDURE PRINT used (Total process time):
       real time           0.01 seconds
       user cpu time       0.01 seconds
       system cpu time     0.00 seconds
       memory              1582.09k
       OS Memory           29352.00k
       Timestamp           03/12/2018 07:39:46 AM
       Step Count                        231  Switch Count  0
       Page Faults                       0
       Page Reclaims                     150
       Page Swaps                        0
       Voluntary Context Switches        0
       Involuntary Context Switches      0
       Block Input Operations            0
       Block Output Operations           8
       
 
 89         
 90         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 102        
Kurt_Bremser
Super User

So let's have a look at your datalines:

 RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     
 
 81  CHAR   .1219 ALAN ranju red 210 192                                                    
     ZONE   03333244442766672766233323332222222222222222222222222222222222222222222222222222
     NUMR   9121901C1E021EA50254021001920000000000000000000000000000000000000000000000000000

First, you can see that your dataline starts with a tab character (hex 09) that should not be there.

Then you use dsd, but have no quotes around text values, and you use a specific position (25-30) for team; looking at the dataline, one can see that there is nothing there after @30, so SAS skips to the next line to read startwi and endwi, stumbling there.

The dsd also causes SAS to interpret the whole line as 1 data item.

Try this code instead:

data club;
infile datalines;
input
  idnumber
  name1 $
  name2 $
  team $
  startwi
  endwi
;
datalines;
1219 ALAN ranju red 210 192
1221 JIM rose YELLOW 220 220
;
run;

 

error_prone
Barite | Level 11
Please don't double post one question.
Removing the blank line after datalines-statement will fix one issue.
SRINIVAS_N
Calcite | Level 5
I had tried removing blankline after datalines still it is not getting
output correctly
s_lassen
Meteorite | Level 14

The problem is that your NAME variable is not read correctly. It consists of first name and last name, but the way you read it only the first name gets into the NAME variable. You can do it like this, provided that you do not suddenly get a person with a middle name:

data club;
infile datalines;
length idnumber 8 firstname lastname $10 team $6 startwi endwi 8;
input idnumber--endwi;
datalines;
1023 DAVID shaw RED 189 155
1049 AMELIA verna YELLOW 145 125
1219 ALAN ranju red 210 192
1246 RAVI shankar YELLOW 177 177
1078 ASHELY valley RED 127 118
1221 JIM rose YELLOW 220 220
;
run;
MG18
Lapis Lazuli | Level 10

 

Below code will also give u ur desired output:-

 

data club;
infile datalines dsd;
input idnumber 1-4 @5 name $14. @20 team $6. @27 startwi 3. @31 endwi;
datalines;
1023 DAVID shaw RED 189 155
1049 AMELIA verna YELLOW 145 125
1219 ALAN ranju red 210 192
1246 RAVI shankar YELLOW 177 177
1078 ASHELY valley RED 127 118
1221 JIM rose YELLOW 220 220
;
proc print data=club;
id idnumber;
run;

s_lassen
Meteorite | Level 14
No, it won't. The program runs without any errors, but it is not correct.
srinath3111
Quartz | Level 8

Hi,

 

The problem is that the data here is non standard data with out delimiter. 

For the non standard data with out delimiter how can you use column input method.?

Why Dsd you have written it is just a space delimiter data?

And After the name the data should contain 2 spaces in the data. or you can split the Name variable into two like first name and lastname.

 

Try.

 

 

data club;
infile datalines;
input idnumber 1-4
name $&13.
team :$
startwi endwi;
datalines;
1023 DAVID shaw RED 189 155
1049 AMELIA verna YELLOW 145 125
1219 ALAN ranju red 210 192
1246 RAVI shankar YELLOW 177 177
1078 ASHELY valley RED 127 118
1221 JIM rose YELLOW 220 220
;
run;

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 13 replies
  • 1240 views
  • 0 likes
  • 6 in conversation