BookmarkSubscribeRSS Feed
Koke
Fluorite | Level 6

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.
4 REPLIES 4
Shmuel
Garnet | Level 18

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.

Koke
Fluorite | Level 6

Oh, my silly mistake Thx.

Reeza
Super User

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.

 

 

Koke
Fluorite | Level 6

Oh, my silly mistake Thx.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 4 replies
  • 899 views
  • 0 likes
  • 3 in conversation