BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ChuksManuel
Pyrite | Level 9

Hello programmers,

 

I have a sas output that i want to format and change into another format using a put statement.

The SAS output and how i want them to look like is in the attached photo.

Died is coded as (Yes/No =1/0). I have attached the codes that i ran. It's giving me all sorts of error and i thing it's a problem with the formatting.

 

Data sasoutput;
input tc	Tn $	Value	LowerCL	UpperCL	death	COUNT	PERCENT;
datalines;
1	Trouble with falling asleep	0.9622	0.7409	1.2497	1	424	16.8656
2	Trouble with waking during night	0.9019	0.7003	1.1617	1	424	16.8656
3	Trouble with waking too early	0.856	0.6434	1.139	1	424	16.879
;run;

data null ; set sasoutput; by tc tn; 
options nodate nonumber; 
file print notitles ;
If _N_ =1 then do; 
put @45 'Died '      ;
put @45 '  N'  @50 '  (%)';  
end;
if first.tc then put / tn $33.  @;  
put @35 value valuefm.  @45  Count 4.   @50 '(' percent  5.2 ')' 
                     ;
run;

output.JPGCapt1.JPG

1 ACCEPTED SOLUTION

Accepted Solutions
heffo
Pyrite | Level 9

Just to clarify, did you create the first data set for the question or is that part of your code? Because it will not work. SAS assumes that the delimiter is space, and you have spaces in the second field (tn), the string with trouble. Also, the variable will only be 8 bytes long, so your full text will be truncated. The rest of your numeric variables will be missing, because SAS will try to put the string "with" into to variable "value" and that will be translated to missing.

View solution in original post

3 REPLIES 3
heffo
Pyrite | Level 9

Just to clarify, did you create the first data set for the question or is that part of your code? Because it will not work. SAS assumes that the delimiter is space, and you have spaces in the second field (tn), the string with trouble. Also, the variable will only be 8 bytes long, so your full text will be truncated. The rest of your numeric variables will be missing, because SAS will try to put the string "with" into to variable "value" and that will be translated to missing.

ChuksManuel
Pyrite | Level 9
Thanks! That was indeed helpful.
ballardw
Super User

You might want to look at the Report Writing Interface which creates "nice" ods tables instead of the plain text that FILE print uses.

 

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!

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
  • 3 replies
  • 590 views
  • 2 likes
  • 3 in conversation