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

Hi , 

 

I ran proc freq on my data (where my remarknew is a character var with certain length). See table below. So remarknew is newly created var and I used a format statement in datastep to change its format to $19. and verified with proc contents. But why is SAS aligning results this way (SAS9.4). I have to change misspelled categories here, but this alignment is just making it annoying to read words. Any help is appreciated?

 

Proc contents results;

46 remarknew Char 19 $19.  
47 id Num 8    
48 ptnew Char 15    
49 case Char 19 $19.  
50 trial Char 19    

 

 

Thanks

~R

 

remarknew Frequency Percent Cumulative
Frequency
Cumulative
Percent
B
A
E
L
I
N
E
1
12 0.15 12 0.15
B
A
S
E
L
I
N
E
1
407 4.97 419 5.12
B
A
S
E
L
I
N
E
2
420 5.13 839 10.25
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Then it's a data issue of sorts. I would first try cleaning the data and removing any hard returns using COMPRESS().

 

data clean;
set old;

newVar = compress(oldVar, ,'s'); *note the two commas;

run;

proc freq data=clean;
table newVar;
run;

@Ruhi wrote:

No I didn't. And its not happening with the data steps you provided. 


 

View solution in original post

15 REPLIES 15
PaigeMiller
Diamond | Level 26

What output destination is this?

--
Paige Miller
Reeza
Super User
What's your output destination? What is your current setting for linesize?
Ruhi
Obsidian | Level 7

I have not set the linesize, its default. ods HTML is output destination. 

Reeza
Super User
Is it happening for all PROC FREQ or just this table?

What happens if you run the following?

proc freq data=sashelp.class;
table name;
run;

If it doesn't happen with that, its related to your data, not the PROC. If it does happen, it's a setting in SAS somewhere most likely.
Ruhi
Obsidian | Level 7

What can I do with my data about this issue? 

Reeza
Super User
Have you ever modified your templates?
Ruhi
Obsidian | Level 7

No I didn't. And its not happening with the data steps you provided. 

Reeza
Super User

Then it's a data issue of sorts. I would first try cleaning the data and removing any hard returns using COMPRESS().

 

data clean;
set old;

newVar = compress(oldVar, ,'s'); *note the two commas;

run;

proc freq data=clean;
table newVar;
run;

@Ruhi wrote:

No I didn't. And its not happening with the data steps you provided. 


 

Ruhi
Obsidian | Level 7

This does not work either, I had already tried it. 

Reeza
Super User
Show the code you tried.
Did you import the data from Excel?
Another method for debugging is to apply a hex format to your data and show us what that looks like.

Ruhi
Obsidian | Level 7
data full_sta;
set full;
where motion_ = "No Motion";
remarknew=input(upcase(compress(remarks,,'s')), $19.);
case=input(compress(remarknew,' ',"d"), $19.);
format remarknew $19. case $19.;
run;

I imported a csv file. I will try hex FORMAT. 

ballardw
Super User

Can you share the code you used to create the variable? And the exact proc freq code used to create the output?

 

Is there a specific reason that variable has a $19. Format assigned? And what was the format prior to you changing it? You don't show any values longer than what should be 9 or 10 characters so I'm not sure why the $19 was considered desirable.

Ruhi
Obsidian | Level 7

I added that format to data, based on how SAS read it from file. So remarks was the original column and I added compress and format to create the new variable remarknew as follows. 

data full_sta;
set full;
	where motion_ = "No Motion";
	remarknew=input(upcase(compress(remarks,,'s')), $19.);
	case=input(compress(remarknew,' ',"d"), $19.);
	format remarknew $19. case $19.;
run;

proc freq data=full_sta;
table remarknew;
run;
Variables in Creation Order
# Variable Type Len Format Informat
1 pt Num 8 NLNUM12. NLNUM32.
2 remarks Char 19 $19. $19.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 15 replies
  • 2379 views
  • 2 likes
  • 4 in conversation