BookmarkSubscribeRSS Feed
harveysarah0
Calcite | Level 5
My code is:
 
PROC IMPORT datafile=mouse;
Mouse; Day3; Day6;   Day9;   Day12;   Day15; Day18; Day21;
1 0.109 0.388  0.621    0.823 1.078 1.132 1.191
2 0.218 0.393  0.568      0.729 0.839 0.852 1.004
3 0.394 0.549     0.700  0.783   0.870 0.925
4 0.209 0.419 0.645     0.850 1.001 1.026 1.069
5 0.193 0.362 0.520      0.530 0.641 0.640 0.751
6 0.201 0.361 0.502      0.530 0.641 0.640 0.751
7 0.202 0.370 0.498    0.650 0.795 0.858 0.910
8 0.190 0.350 0.666 0.819 0.879 0.929
9 0.219 0.399 0.578  0.699 0.709 0.822 0.953
10 0.255 0.400 0.545  0.690 0.796 0.825 0.836
11 0.224 0.381 0.577  0.756 0.869 0.929 0.999
12 0.187 0.329 0.441 0.525 0.621 0.796
13 0.278 0.471 0.606 0.770 0.888 1.001 1.105
;
RUN
 
 
My output is:


262 PROC IMPORT datafile=mouse;
ERROR: Output SAS data set must be provided.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

263 Mouse; Day3; Day6; Day9; Day12; Day15; Day18; Day21;
264 1 0.109 0.388 0.621 0.823 1.078 1.132 1.191
265 2 0.218 0.393 0.568 0.729 0.839 0.852 1.004
266 3 0.394 0.549 0.700 0.783 0.870 0.925
267 4 0.209 0.419 0.645 0.850 1.001 1.026 1.069
268 5 0.193 0.362 0.520 0.530 0.641 0.640 0.751
269 6 0.201 0.361 0.502 0.530 0.641 0.640 0.751
270 7 0.202 0.370 0.498 0.650 0.795 0.858 0.910
271 8 0.190 0.350 0.666 0.819 0.879 0.929
272 9 0.219 0.399 0.578 0.699 0.709 0.822 0.953
273 10 0.255 0.400 0.545 0.690 0.796 0.825 0.836
274 11 0.224 0.381 0.577 0.756 0.869 0.929 0.999
275 12 0.187 0.329 0.441 0.525 0.621 0.796
276 13 0.278 0.471 0.606 0.770 0.888 1.001 1.105
277 ;
278 RUN

 

I am trying to create a new dataset.

 
7 REPLIES 7
fdsaaaa
Obsidian | Level 7
data mouse;
infile datalines truncover;
input Mouse  Day3  Day6    Day9    Day12    Day15  Day18  Day21;
datalines;
1 0.109 0.388  0.621    0.823 1.078 1.132 1.191
2 0.218 0.393  0.568      0.729 0.839 0.852 1.004
3 0.394 0.549     0.700  0.783   0.870 0.925
4 0.209 0.419 0.645     0.850 1.001 1.026 1.069
5 0.193 0.362 0.520      0.530 0.641 0.640 0.751
6 0.201 0.361 0.502      0.530 0.641 0.640 0.751
7 0.202 0.370 0.498    0.650 0.795 0.858 0.910
8 0.190 0.350 0.666 0.819 0.879 0.929
9 0.219 0.399 0.578  0.699 0.709 0.822 0.953
10 0.255 0.400 0.545  0.690 0.796 0.825 0.836
11 0.224 0.381 0.577  0.756 0.869 0.929 0.999
12 0.187 0.329 0.441 0.525 0.621 0.796
13 0.278 0.471 0.606 0.770 0.888 1.001 1.105
;
RUN;

You have some lines that do not have values for all of the variables - e.g. Mouse 3 . 

This code assumes that it is the last variable (Day 21)  that is missing - I can't tell from your formatting if this is a valid assumption . 

harveysarah0
Calcite | Level 5

How do I upload a text file so the formatting is not off? This is the file.

fdsaaaa
Obsidian | Level 7

you initially said this was your code

PROC IMPORT datafile=mouse;
Mouse; Day3; Day6;   Day9;   Day12;   Day15; Day18; Day21;
1 0.109 0.388  0.621    0.823 1.078 1.132 1.191
2 0.218 0.393  0.568      0.729 0.839 0.852 1.004
3 0.394 0.549     0.700  0.783   0.870 0.925
4 0.209 0.419 0.645     0.850 1.001 1.026 1.069
5 0.193 0.362 0.520      0.530 0.641 0.640 0.751
6 0.201 0.361 0.502      0.530 0.641 0.640 0.751
7 0.202 0.370 0.498    0.650 0.795 0.858 0.910
8 0.190 0.350 0.666 0.819 0.879 0.929
9 0.219 0.399 0.578  0.699 0.709 0.822 0.953
10 0.255 0.400 0.545  0.690 0.796 0.825 0.836
11 0.224 0.381 0.577  0.756 0.869 0.929 0.999
12 0.187 0.329 0.441 0.525 0.621 0.796
13 0.278 0.471 0.606 0.770 0.888 1.001 1.105
;
RUN
 

that would be the incorrect way to create a dataset , because you don't use proc import and then type in the values.

Are you saying your data is actually in an external file?

ed_sas_member
Meteorite | Level 14

Hi @harveysarah0 

 

Here is one approach using datelines (you write the values in the code). The The double trailing @@ is useful to indicate that a record needs to be reread on the next iteration of the DATA step.

DLM="09"x indicates that values are separated by a tabulation.

DSD indicates that there can be missing values (two delimiters are not interpreted as a single one).

data mouse;
	infile datalines dlm="09"x dsd;
	input Mouse	Day3 Day6 Day9 Day12 Day15 Day18 Day21 @@;
	datalines;
1	0.109	0.388	0.621
0.823	1.078	1.132	1.191
2	0.218	0.393	0.568
0.729	0.839	0.852	1.004
3	0.394		0.549
0.700	0.783	0.870	0.925
4	0.209	0.419	0.645
0.850	1.001	1.026	1.069
5	0.193	0.362	0.520
0.530	0.641	0.640	0.751
6	0.201	0.361	0.502
0.530	0.641	0.640	0.751
7	0.202	0.370	0.498
0.650	0.795	0.858	0.910
8	0.190	0.350	
0.666	0.819	0.879	0.929
9	0.219	0.399	0.578
0.699	0.709	0.822	0.953
10	0.255	0.400	0.545
0.690	0.796	0.825	0.836
11	0.224	0.381	0.577
0.756	0.869	0.929	0.999
12	0.187	0.329	0.441
0.525		0.621	0.796
13	0.278	0.471	0.606
0.770	0.888	1.001	1.105
;
run;

You can also directly import the txt file:

proc import datafile="/path/MiceWeight.txt" /*update the physical path*/
	        out=mouse
	        dbms=tab
	        replace;
run;
ballardw
Super User

@harveysarah0 wrote:

How do I upload a text file so the formatting is not off? This is the file.


 

At the top of the message window is a row of icons. If you click on the one that looks like {I} then you will get a code box that treats pasted text as is and will not reformat. The result will look something like

 

This is my plain text
1   2    3
5   6    999

Or the "running man" icon, which will provide syntax highlighting for SAS code.

harveysarah0
Calcite | Level 5

I still receive this error after fixing my formatting. 

 


NOTE: Attachments for -3 reestablished for new parent.
NOTE: Import Cancelled.
315 PROC IMPORT datafile=mouse;
ERROR: Output SAS data set must be provided.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds

 

 

 

This is my new code:

PROC IMPORT datafile=mouse;
Mouse Day3 Day6 Day9 Day12 Day15 Day18 Day21
1 0.109 0.388 0.621. 0.823 1.078 1.132 1.191
2 0.218 0.393 0.568 0.729 0.839 0.852 1.004
3 0.394 0.549 0.700 0.783 0.870 0.925
4 0.209 0.419 0.645. 0.850 1.001 1.026 1.069
5 0.193 0.362 0.520. 0.530 0.641 0.640 0.751
6 0.201 0.361 0.502. 0.530 0.641 0.640 0.751
7 0.202 0.370 0.498. 0.650 0.795 0.858 0.910
8 0.190 0.350 0.666 0.819 0.879 0.929.
9 0.219 0.399 0.578 0.699 0.709 0.822 0.953
10 0.255 0.400 0.545. 0.690 0.796 0.825 0.836
11 0.224 0.381 0.577. 0.756 0.869 0.929 0.999
12 0.187 0.329 0.441. 0.525 0.621 0.796
13 0.278 0.471 0.606 0.770 0.888 1.001 1.105

;
RUN

 

harveysarah0
Calcite | Level 5

It does not look properly formatted here but I lined everything up in SAS.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 7 replies
  • 1024 views
  • 0 likes
  • 4 in conversation