BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
SASnovice23
Calcite | Level 5

I have a numeric column which records the number of deaths per year by gender. In order to calculate the total number of deaths per gender, I used the following code:

PROC SUMMARY DATA=DATA1 NWAY;
VAR no_deaths;
CLASS GENDER_CODE;
OUTPUT OUT=OUT2 (DROP=_TYPE_) SUM=;
RUN;

and this is what I get: a * is displayed instead of displaying a numeric value. What might be the issue? I also tried using query builder > computed columns, but the same problem persists.

Snap8.png

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Somehow you have assigned a format that none of the resulting values will display with.

Consider this small program that writes the value of the variable X to the results with 5 different formats:

data example;
  x=12345;
  file print;
  put '5 display columns' x= best5.;
  put '4 display columns' x= best4.;
  put '3 display columns' x= best3.;
  put '2 display columns' x= best2.;
  put '1 display columns' x= best1.;
run;

Which generates output like:

5 display columns x=12345                                                                          
4 display columns x=12E3                                                                           
3 display columns x=1E4                                                                            
2 display columns x=**                                                                             
1 display columns x=*                                                                              

 


You can see that when the value is longer than the number of columns allotted by the format that the BEST format shifts to exponential notation to try to fit the value but when the number of allowed digits is down to 2 or 1 it only displays the * because there is not valid way to show the number. The behavior will change depending on the format actually assigned.
 
You could either assign a different format in the proc summary step adding something like :
format no_deaths f8.;
which would allow displaying values up to 8 digits (or use a wider format if needed), change the format in the data set Out2, or assign a different format when using the set. The table viewer you are uses the default assigned format which seems likely to be a 1 width format of some sort
See what this shows:
Proc print data=out2 noobs label;
   format no_deaths best16.;
run;
The data set has the value, you just don't see it because of the format. The proc print should show it.
 

@SASnovice23 wrote:

I have a numeric column which records the number of deaths per year by gender. In order to calculate the total number of deaths per gender, I used the following code:

PROC SUMMARY DATA=DATA1 NWAY;
VAR no_deaths;
CLASS GENDER_CODE;
OUTPUT OUT=OUT2 (DROP=_TYPE_) SUM=;
RUN;

and this is what I get: a * is displayed instead of displaying a numeric value. What might be the issue? I also tried using query builder > computed columns, but the same problem persists.

Snap8.png


 

View solution in original post

1 REPLY 1
ballardw
Super User

Somehow you have assigned a format that none of the resulting values will display with.

Consider this small program that writes the value of the variable X to the results with 5 different formats:

data example;
  x=12345;
  file print;
  put '5 display columns' x= best5.;
  put '4 display columns' x= best4.;
  put '3 display columns' x= best3.;
  put '2 display columns' x= best2.;
  put '1 display columns' x= best1.;
run;

Which generates output like:

5 display columns x=12345                                                                          
4 display columns x=12E3                                                                           
3 display columns x=1E4                                                                            
2 display columns x=**                                                                             
1 display columns x=*                                                                              

 


You can see that when the value is longer than the number of columns allotted by the format that the BEST format shifts to exponential notation to try to fit the value but when the number of allowed digits is down to 2 or 1 it only displays the * because there is not valid way to show the number. The behavior will change depending on the format actually assigned.
 
You could either assign a different format in the proc summary step adding something like :
format no_deaths f8.;
which would allow displaying values up to 8 digits (or use a wider format if needed), change the format in the data set Out2, or assign a different format when using the set. The table viewer you are uses the default assigned format which seems likely to be a 1 width format of some sort
See what this shows:
Proc print data=out2 noobs label;
   format no_deaths best16.;
run;
The data set has the value, you just don't see it because of the format. The proc print should show it.
 

@SASnovice23 wrote:

I have a numeric column which records the number of deaths per year by gender. In order to calculate the total number of deaths per gender, I used the following code:

PROC SUMMARY DATA=DATA1 NWAY;
VAR no_deaths;
CLASS GENDER_CODE;
OUTPUT OUT=OUT2 (DROP=_TYPE_) SUM=;
RUN;

and this is what I get: a * is displayed instead of displaying a numeric value. What might be the issue? I also tried using query builder > computed columns, but the same problem persists.

Snap8.png


 

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 520 views
  • 0 likes
  • 2 in conversation