BookmarkSubscribeRSS Feed
EricB40
Fluorite | Level 6

How do I code this data to be read as one observation spanning over three lines? 

This is what the data looks like.

00001150200070750242704380517069207391136212115111383014030100010210164007220090517
62136133691701143081090101010484051999299110 990 01101101117100000000001-1-1-1-1-1-
10301-1-1-12
00001251800070755262915311589160618151410122115211042844040100010310174306420091631
631341406919411430810801020205850714021011201035001101101119200000000001-101-1-1-
102-101-1-1-12
00002155000050500263404420517999905741099211199939991327010000000120154210541590517
65133135701551 05991000103030382051999 9911 996 7100000000004011041010000030301-
10299030701-19
00004159900059900429903950517999906651099211105111022704050190010420143809990060517
6411899999999 9999 9999999999 99 99 99 99 8 99 99 99 99 99
999999999999999999999999991
00005155000070750273702580517999905541099212101211272964030011010320364002140090517
65247225691771118091050104040582051999 99111 064 01000000000050000000002-101-1-1-
19999990699992
00005252200070756324221922262227024841411122111251172924040011010420164209041592354
6523223399999111808105010505058206140710311120640010000000000500000000020200-1-1-1-
1-1-199-1992
000071502000707002426036105179999062710992111092111526640310000102108
380521009051762121107661581 3699106010101040309199929911 990
01000000000000000000002-101-1-1-1-1-102-1-1-12
000081550000707002833036405179999061910992111091113125530502000203906
120822009051762125109999991 0499109010101058 99 999 999 010 011011012201 99 99
9900030102-1-19999999999992
00009155020050500369904480517999907131099211199211422654030000000320164004550090517
65150150691951 46996000502980581071499 9911 991 71202205790410110720206-104-1-1-
109-10202-1009
00010155020050500202103900518999906741099211118211182844010000000120174002420090518
63112105741901 54993000101010383051999 9911 991 211011021161101102202010000-1-1-
104-10201-1001
00011150200009960303004360518999907291099212123111592934000000000000000000550090518
65132122711801905005000603980289051999199119 992 01202201790400380170905-1020302-
102-1020001-11
00012155000000700192303980518999906421099211118210752441010000000110123302220090518
62115106711601 60993030101010382051999 9911 995 710000000000101104206-102-1-1-1-
102-10100-1-15
00013150200009910232704390518999907171099212110211122784010000000120183604320090553
66120110742201147091050101010383981999 99119 992 71000000000000380470900-102-1-1-
104-1020301011
00013251200000115263014491535154317401413122108211232914020000000220163906230091543
6611510673220114709105080604048206140410311920901211011013181101107109-1-104-1-
10102-1000609021
00014155000059960192804000518999906791099214116110992794000000000000000000320090518
62114105671951160001050101010282091999 9911 991 010000000000000000000-1-103-1-1-
19999019999991
00014250300050665202907450983098310311234124110211122864010000000110143901320090983
6114799999999116000105080202038299140010012
00000100000000000000000009999999999999999999999991
00014351600050665243321122191220723871313134110211082754020000000220164007320092207
6212612070175 16000105010606048205 40910912 9960710000000000 99 99 9901-102-1-1-
19999999999991
00014450500050565263529152982299931931412144103111352784030000000320153904320092999
6112412069185116000105010707058209 40910912 000001000000000010110110902-10100-1-
103-100-1-1001
00015150200089950252903980517999906741099213120211062764000000000000000000550090538
62102094651151569005000900000283031499199119 990 710000000000000000000-10101-1-1-1-
10000-1-1-13
00015251600080858273111271219123514111415123113111202844010000000120153904550091241
6210610065110156900600010101988399140120111910000010000000000000000000-102-1-1-1-1-
 
and this is what I have so far

Data pregnancy;
Infile '/home/u63556826/sasuser.v94/BASIC50.DAT' missover;
Input
#1 Woman 1-5 Gravage 18-19
BirthWT 50-52 /
GRHEIGHT 84-85
GRWEIGHT 86-88 /

;

run;

proc print data=pregnancy;

run;

 
2 REPLIES 2
Patrick
Opal | Level 21

If it's always 3 source lines that need to map into a single SAS observation then code similar to below should work.

data demo;
  infile datalines truncover;
  input 
    #1 Woman 1-5 Gravage 18-19 BirthWT 50-52
    #2 someVar 9-15
    #3 someOtherVar $1-20
  ;
  datalines;
00001150200070750242704380517069207391136212115111383014030100010210164007220090517
62136133691701143081090101010484051999299110 990 01101101117100000000001-1-1-1-1-1-
10301-1-1-12
00001251800070755262915311589160618151410122115211042844040100010310174306420091631
631341406919411430810801020205850714021011201035001101101119200000000001-101-1-1-
102-101-1-1-12
;
ballardw
Super User

First, administrative stuff: Pasting ANY text into the main message window is subject to the forum software reformatting the text, generally removing white space but other things occur depending on exact pasted stuff.

So if you want to show us text, open a text box using the </> icon above the main message window and paste the text there.

 

It will help if you can show us what you mean by " read as one observation spanning over three lines". It is possible to read multiple lines at a time as a single observation. But I do not see any thing from your description that tells us what value goes into what variable.

 

The / on the input statement is an instruction to advance to the next line. An example (and shows what a text box looks like)

data example;
  input x 1-3 y 4-6
       / z 1-5 a 6
       / b 4-5 c 7-8  ;
datalines;
123456789
123456789
123456789
;

I tend to place the / on the input statement so it is a bit easier to follow the code as to what I expect to read.

 

If your data is fixed column, which is the only way I can interpret what I see so far, you will need to count out each column for the variable you want. OR find a document that has the information for which variables start where. If you have such and have a hard time reading the data then share that document with us.

 

If any of the - in the body of that stuff does not start a negative numeric value you will have to provide a character format to read the values.

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 314 views
  • 2 likes
  • 3 in conversation