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 |
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.
What output destination is this?
ods html .
I have not set the linesize, its default. ods HTML is output destination.
What can I do with my data about this issue?
No I didn't. And its not happening with the data steps you provided.
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.
This does not work either, I had already tried it.
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.
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.
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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.