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;
Hi:
First, look at the YearMon values, such as with PROC FREQ:
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:
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:
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 wrote:
Does anyone know where 1 and 6 came from after YearMon?
Hi:
First, look at the YearMon values, such as with PROC FREQ:
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:
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:
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
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!
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.