DATA Step, Macro, Functions and more

reading in data

Accepted Solution Solved
Reply
Contributor
Posts: 27
Accepted Solution

reading in data

Hi, I have tried to read this data in several diffferent ways and cannot get it to align correctly. The code and the results are below.  The visitmnemonic column keeps reading too much and if I shorten the length then the first obs is also shortened. Thanks in advance for your help.

 

data widepe ;
input @1 subjectnumberstr $9. @11 visitmnemonic $9. pegenap_c & $31. ;
datalines;
0100-1204 screening Abnormal, please specify
0100-1204 eos/et Normal
;
run;
proc print data = widepe; run;

 

SAS Output

Obs subjectnumberstr visitmnemonic pegenap_c
1 0100-1204 screening Abnormal, please specify
2 0100-1204 eos/et N ormal

Accepted Solutions
Solution
‎05-05-2017 01:55 AM
Super User
Posts: 6,936

Re: reading in data

Use colons before the formats so that the blanks as column separators are not overridden:

data widepe;
input subjectnumberstr :$9. visitmnemonic :$9. pegenap_c & :$31.;
datalines;
0100-1204 screening Abnormal, please specify
0100-1204 eos/et Normal
;
run;

proc print data=widepe;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎05-05-2017 01:55 AM
Super User
Posts: 6,936

Re: reading in data

Use colons before the formats so that the blanks as column separators are not overridden:

data widepe;
input subjectnumberstr :$9. visitmnemonic :$9. pegenap_c & :$31.;
datalines;
0100-1204 screening Abnormal, please specify
0100-1204 eos/et Normal
;
run;

proc print data=widepe;
run;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 27

Re: reading in data

Thank you very much!

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 97 views
  • 0 likes
  • 2 in conversation