BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
sann123
Fluorite | Level 6
  1. Does anyone know where 1 and 6 came from after YearMon?
     

    pic1.png

     
     
     
     
    Also in this one it said to include commas and zero decimal places how did they decide comma6. and comma10. instead of any other number?
     
    pic2.png
     
     
    Lastly, 

    Where am I supposed to be looking for How many storms are in PressureGroup 1?

     

    I did the following but wrote 3118 and it was wrong. Please advice what is correct answer and where you saw it.

     

    data storm_cat;

    set pg1.storm_summary; keep Name Basin MinPressure StartDate PressureGroup;

    *add ELSE keyword and remove final condition;

    if MinPressure=. then PressureGroup=.;

    else if MinPressure<=920 then PressureGroup=1;

    else PressureGroup=0;

    run;

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  First, look at the YearMon values, such as with PROC FREQ:

Cynthia_sas_0-1659316015258.png

 

  Note that Year is specified in the first 4 positions of the variable and Month value is in positions 6-7, the constant letter M is in position 5. Then, as suggested, review the lecture or read the documentation on the use of the SUBSTR function and the MDY function. Here's the breakdown:

Cynthia_sas_1-1659316128262.png

 

  Regarding your second question about "how did they decide" which number to use with the format for comma -- either 6 or 10, that comes down to knowing your data well -- what is the largest possible value, how do you want that value to be displayed, how many extra punctuation characters will be needed to display the largest number. It never hurts to specify a larger value than you think you'll need. Let's say you have a variable called VarX that has a possible minimum value of 3 digits and a possible maximum value of 8 digits. To display the minimum and the maximum using commas as the thousand separator, you need at least 2 commas as shown below:

Cynthia_sas_2-1659316620218.png

  The largest number that could be displayed without formatting problems is 99999999, which would need a format of comma10. to display as 99,999,999.

 

  Last, 3118 is the total number of rows in the pg1.storm_summary data file. If all the storms were in Pressure Group 1, that would be the right answer. However, there is a procedure which will show you the number of rows that fall into Pressure Group 1 vs Pressure Group 0 or missing. You could either run PROC FREQ on your output data WORK.STORM_CAT or you could run some other procedure. But running PROC FREQ would be the method I would recommend.

 

Hope this helps point you in the right direction,

Cynthia

 

View solution in original post

3 REPLIES 3
mkeintz
PROC Star


@sann123 wrote:
  1. Does anyone know where 1 and 6 came from after YearMon?

 

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Cynthia_sas
SAS Super FREQ

Hi:

  First, look at the YearMon values, such as with PROC FREQ:

Cynthia_sas_0-1659316015258.png

 

  Note that Year is specified in the first 4 positions of the variable and Month value is in positions 6-7, the constant letter M is in position 5. Then, as suggested, review the lecture or read the documentation on the use of the SUBSTR function and the MDY function. Here's the breakdown:

Cynthia_sas_1-1659316128262.png

 

  Regarding your second question about "how did they decide" which number to use with the format for comma -- either 6 or 10, that comes down to knowing your data well -- what is the largest possible value, how do you want that value to be displayed, how many extra punctuation characters will be needed to display the largest number. It never hurts to specify a larger value than you think you'll need. Let's say you have a variable called VarX that has a possible minimum value of 3 digits and a possible maximum value of 8 digits. To display the minimum and the maximum using commas as the thousand separator, you need at least 2 commas as shown below:

Cynthia_sas_2-1659316620218.png

  The largest number that could be displayed without formatting problems is 99999999, which would need a format of comma10. to display as 99,999,999.

 

  Last, 3118 is the total number of rows in the pg1.storm_summary data file. If all the storms were in Pressure Group 1, that would be the right answer. However, there is a procedure which will show you the number of rows that fall into Pressure Group 1 vs Pressure Group 0 or missing. You could either run PROC FREQ on your output data WORK.STORM_CAT or you could run some other procedure. But running PROC FREQ would be the method I would recommend.

 

Hope this helps point you in the right direction,

Cynthia

 

sann123
Fluorite | Level 6
Thank you so much Cynthia. That was a really good answer that I was looking for with pictures and all. Really appreciate your help.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 1218 views
  • 0 likes
  • 3 in conversation