DATA Step, Macro, Functions and more

creating txt.

Reply
Occasional Contributor
Posts: 17

creating txt.

Hello all,

I'm trying to create a text file, and print it. However, it did not show anything in the output. I use sas univeristy edition.

I really not sure that 

A shared folder named "myfolders" was not found on the virtual machine. See the FAQ for details.

this message that show in the notification effect the problem or not.

Need help

My example data from (infile).txt 

11
Xxxxxxxx Yyyy 
XX 
5-8
YY 
2X

 

Here is my code

data _null_
;
infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" delimiter="-"
;
Input number $ 2. #2 firstname $ 1-8 lastname $ 11. #3 code $ #4 feet 1. inches #5
level $ #6 jersey $
;
file "/folders/myfolders/soccer.txt" print;
Title;
Put @2 firstname lastname 'wear Number' @1 number ;
Put;
run;

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data _null_
63 ;
64 infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" delimiter="-"
65 ;
66 Input number $ 2. #2 firstname $ 1-8 lastname $ 11. #3 code $ #4 feet 1. inches #5
67 level $ #6 jersey $
68 ;
69 file "/folders/myfolders/soccer.txt" print;
70 Title;
71 Put @2 firstname lastname 'wear Number' @1 number ;
72 Put;
73 run;
 
NOTE: The infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" is:
(no system-specific pathname available),
(no system-specific file attributes available)
 
NOTE: The file "/folders/myfolders/soccer.txt" is:
(no system-specific pathname available),
(no system-specific file attributes available)
 
NOTE: 192 records were read from the infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt".
The minimum record length was 22.
The maximum record length was 22.
NOTE: 32 records were written to the file "/folders/myfolders/soccer.txt".
The minimum record length was 23.
The maximum record length was 30.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.02 seconds
 
 
74
75
76
77
78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
91
 
Thank.
Trusted Advisor
Posts: 1,586

Re: creating txt.

It seems that the output text file was created fine.

 

I don't see any code for printing it. The put statemane writes to the output text file.

Occasional Contributor
Posts: 17

Re: creating txt.

Oh, my silly mistake Thx.

Super User
Posts: 19,878

Re: creating txt.

You're reading from the same file you're writing back to (soccer.txt). That makes it hard to test and check anything. I would suggest changing the second file to a different name to see if you get what you need. The other big issue with this type of coding is that you've destroyed the original file, so if you did it wrong and replaced the file, which it looks like you did, you'll have to replace your original soccer file to start again.

 


Koke wrote:

Hello all,

I'm trying to create a text file, and print it. However, it did not show anything in the output. I use sas univeristy edition.

 



Your code is reading a text file and then writing back to that text file some of the variables. I suspect this isn't what you want. 

Do you want to import a text file into SAS and then use PROC PRINT to display your data?

 


Koke wrote:

Hello all,

I'm trying to create a text file, and print it. However, it did not show anything in the output. I use sas univeristy edition.

I really not sure that 

A shared folder named "myfolders" was not found on the virtual machine. See the FAQ for details.

this message that show in the notification effect the problem or not.

Need help

My example data from (infile).txt 

11
Xxxxxxxx Yyyy 
XX 
5-8
YY 
2X

 

Here is my code

data _null_
;
infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" delimiter="-"
;
Input number $ 2. #2 firstname $ 1-8 lastname $ 11. #3 code $ #4 feet 1. inches #5
level $ #6 jersey $
;
file "/folders/myfolders/soccer.txt" print;
Title;
Put @2 firstname lastname 'wear Number' @1 number ;
Put;
run;

 

1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 data _null_
63 ;
64 infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" delimiter="-"
65 ;
66 Input number $ 2. #2 firstname $ 1-8 lastname $ 11. #3 code $ #4 feet 1. inches #5
67 level $ #6 jersey $
68 ;
69 file "/folders/myfolders/soccer.txt" print;
70 Title;
71 Put @2 firstname lastname 'wear Number' @1 number ;
72 Put;
73 run;
 
NOTE: The infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt" is:
(no system-specific pathname available),
(no system-specific file attributes available)
 
NOTE: The file "/folders/myfolders/soccer.txt" is:
(no system-specific pathname available),
(no system-specific file attributes available)
 
NOTE: 192 records were read from the infile "/folders/myshortcuts/SASUniversityEdition/module 2/soccer.txt".
The minimum record length was 22.
The maximum record length was 22.
NOTE: 32 records were written to the file "/folders/myfolders/soccer.txt".
The minimum record length was 23.
The maximum record length was 30.
NOTE: DATA statement used (Total process time):
real time 0.11 seconds
cpu time 0.02 seconds
 
 
74
75
76
77
78 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
91
 
Thank.

 

 

Occasional Contributor
Posts: 17

Re: creating txt.

Oh, my silly mistake Thx.

Ask a Question
Discussion stats
  • 4 replies
  • 118 views
  • 0 likes
  • 3 in conversation