DATA Step, Macro, Functions and more

data step dateline and cards

Reply
Regular Contributor
Posts: 199

data step dateline and cards

[ Edited ]

Hello all,

I use SAS 9.4 PC version,

I have to add extra space between rows of dataline(cards),   otherwise will miss half data. please help.

I don't know why my post will add extra space automatically,if you copy my code there will be spaces betwween rows of data. my code don't has extra space.

data layout;

input a $1-500 ;

cards;

@1 CLASS $40.

@45 ID $10.

@61 Gailer $100.

@161 Mid $20.

@181 PERMIT $8.

@189 DEST $8.

@197 Rur $8.

@205 Month $8.

@223 Mac $40.

@263 Product $40.

@303 Weight_Range $8.

@326 Revenue 8.

@338 Pieces 8.

@350 Weight 8.

@365 MC_Doc $10.

@382 CP_Doc $10.

;

run;

 

 

data layout2;

input a $1-500 ;

cards;

@1 CLASS $40.

@45 ID $10.

@61 Gailer $100.

@161 Mid $20.

@181 PERMIT $8.

@189 DEST $8.

@197 Rur $8.

@205 Month $8.

@223 Mac $40.

@263 Product $40.

@303 Weight_Range $8.

@326 Revenue 8.

@338 Pieces 8.

@350 Weight 8.

@365 MC_Doc $10.

@382 CP_Doc $10.

;

run;

 

 

Thanks

Contributor
Posts: 28

Re: data step dateline and cards

First. 

This process looks strange to me.  The reading of input criteria as card statements.

I wont judge as maybe you are using that as a mock up.

 

but try this...

 

data layout;
infile cards missover;
input a $1-500 ;
cards;
/** your card stuff **/
;
run;

hth

 

zeke torres

www.wcsug.com

Super User
Posts: 6,927

Re: data step dateline and cards

@zeketorres_sasaholic: missover won't work, as a is then set to missing on all observations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 28

Re: data step dateline and cards

Kurt.

 

thanks - you are correct.

i did copy/cut/paste his code over and felt the infile would do the trick.

i tried before/after.

i got lazy on doing a proc print to test (although i did look at the log).

hence the half ass-ed success.

mea culpa.

 

fwiw - i have opted to not make any suggestions without the appropriate amount of coffee to complexity ratio.

 

best

z

Super User
Posts: 6,927

Re: data step dateline and cards

Add

infile cards truncover;

before the input statement. Your explicit definition of $1-500 forces SAS to look for more characters than are present on the dataline, and so it skips to the next line. This is NOTEd in the log.

The truncover option just tells SAS to be OK with what's there on the input line, and not skip.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 4 replies
  • 319 views
  • 3 likes
  • 3 in conversation