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

Is StormType="Tropical Storm; necessary to create the new column MaxWindKM?  If not, what information is StormType pulling from to make the new column Tropical Storm?

 

data tropical_storm;

set pg1.storm_summary;

drop Hem_EW HEM_NS Lat Lon;

where Type="TS";

MaxWindKM=MaxWindMPH*1.60934;

format MaxWindKM 3.;

StormType="Tropical Storm";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Panagiotis
SAS Employee

Hi @AJS1 ,

 

Let me see if I understand your question correct. You are asking if the statement StormType="Tropical Storm"; is required to create the new column MaxWindKM?

 

The answer is no, it's not necessary. The StormType='Tropical Storm' creates another column that essentially explains what the Type column means. If you look at the Type column you will see a TS. TS is an abbreviation, so you decided to add another column that explains TS (or Tropical Storm).

 

One way to check is to break everything down and test it. First I suggestion run the DATA step without the StormType='Tropical Storm' and see what happens. In this example I commented out StormType='Tropical Storm'.

 

 

data tropical_storm;
  set pg1.storm_summary;
  drop Hem_EW HEM_NS Lat Lon;
  where Type="TS";
  MaxWindKM=MaxWindMPH*1.60934;
  format MaxWindKM 3.;
  *StormType="Tropical Storm";
run;

Results:

reuslts1.jpg

 

You can see that the MaxWindKM was still created from the assignment statement in yourcode (MaxWindKM=MaxWindMPH*1.60934). However you don't have the StormType column. 

 

So let's add back in StormType='Tropical Storm' and see our results.

 

data tropical_storm;
  set pg1.storm_summary;
  drop Hem_EW HEM_NS Lat Lon;
  where Type="TS";
  MaxWindKM=MaxWindMPH*1.60934;
  format MaxWindKM 3.;
  StormType="Tropical Storm";
run;

Results:

 

 

results2.jpg

 

 

 

 

All you are doing with those assignment statements is creating a new column. In the case of the MaxWindKM you are creating a new column based on a calculation for each row. The new StormType column is being created with a static string. Try adding another column or two and see the different results.

 

Hope this helps. Please let me know if you have any other questions.

 

- Peter

 

 

 

 

 

View solution in original post

5 REPLIES 5
Reeza
Super User

Is StormType="Tropical Storm; necessary to create the new column MaxWindKM

No, they are independent statements.

 

If not, what information is StormType pulling from to make the new column Tropical Storm?

No information is being 'pulled' it's what you can a manual coding or hard coded value. 

I'm assuming someone is creating a label that will make sense when the file is combined with other files to indicate the other storm types. 

 


@AJS1 wrote:

Is StormType="Tropical Storm; necessary to create the new column MaxWindKM?  If not, what information is StormType pulling from to make the new column Tropical Storm?

 

data tropical_storm;

set pg1.storm_summary;

drop Hem_EW HEM_NS Lat Lon;

where Type="TS";

MaxWindKM=MaxWindMPH*1.60934;

format MaxWindKM 3.;

StormType="Tropical Storm";

run;


 

Panagiotis
SAS Employee

Hi @AJS1 ,

 

Let me see if I understand your question correct. You are asking if the statement StormType="Tropical Storm"; is required to create the new column MaxWindKM?

 

The answer is no, it's not necessary. The StormType='Tropical Storm' creates another column that essentially explains what the Type column means. If you look at the Type column you will see a TS. TS is an abbreviation, so you decided to add another column that explains TS (or Tropical Storm).

 

One way to check is to break everything down and test it. First I suggestion run the DATA step without the StormType='Tropical Storm' and see what happens. In this example I commented out StormType='Tropical Storm'.

 

 

data tropical_storm;
  set pg1.storm_summary;
  drop Hem_EW HEM_NS Lat Lon;
  where Type="TS";
  MaxWindKM=MaxWindMPH*1.60934;
  format MaxWindKM 3.;
  *StormType="Tropical Storm";
run;

Results:

reuslts1.jpg

 

You can see that the MaxWindKM was still created from the assignment statement in yourcode (MaxWindKM=MaxWindMPH*1.60934). However you don't have the StormType column. 

 

So let's add back in StormType='Tropical Storm' and see our results.

 

data tropical_storm;
  set pg1.storm_summary;
  drop Hem_EW HEM_NS Lat Lon;
  where Type="TS";
  MaxWindKM=MaxWindMPH*1.60934;
  format MaxWindKM 3.;
  StormType="Tropical Storm";
run;

Results:

 

 

results2.jpg

 

 

 

 

All you are doing with those assignment statements is creating a new column. In the case of the MaxWindKM you are creating a new column based on a calculation for each row. The new StormType column is being created with a static string. Try adding another column or two and see the different results.

 

Hope this helps. Please let me know if you have any other questions.

 

- Peter

 

 

 

 

 

AJS1
Obsidian | Level 7

How does the program know that TS is the same as Tropical Storm?  

 

Thank you.

Tom
Super User Tom
Super User

@AJS1 wrote:

How does the program know that TS is the same as Tropical Storm?  

 

Thank you.


The program does not know that.  The programmer knew that and so that is why they wrote the program in this way.

Panagiotis
SAS Employee

When you wrote StormType='Tropical Storm' you told it. The program only knows that because of you, the programmer.

 

For fun, change 'Tropical Storm' to any other string. Just put your name in it for instance. When you run the program you will now have a column full of your name as the value. Now obviously that is not correct when analyzing storm data, but hopefully you see what you are doing. 

 

In this specific demo, we are telling you to do it. When working with real world data at work you will have to know about your data, and what abbreviations mean.

 

Hope that helped.

 

- Peter

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 5 replies
  • 956 views
  • 6 likes
  • 4 in conversation