BookmarkSubscribeRSS Feed
ybz12003
Rhodochrosite | Level 12

Hello:

 

I would like to program a Macro procedure when the State name shown in the State column, it will corrospored to assign a certain number to the GEO_JUR column.  Therefore, if the same situation happens again, it will save my time.  Please see my SAS data.

However, I don't know how.   Please help.  Thanks.

 

Ying

 

%macro ASSIGNGEO(&State,GEO_JUR);
length GEO_JUR $10.;
IF &State="Alabama" THEN GEO_JUR="01";
IF &State="Alaska" THEN GEO_JUR="02";
IF &State="Arizona" THEN GEO_JUR="04";
IF &State="Arkansas" THEN GEO_JUR="05";
IF &State="California" THEN GEO_JUR="06";
IF &State="Colorado" THEN GEO_JUR="08";
IF &State="Connecticut" THEN GEO_JUR="09";
IF &State="Delaware" THEN GEO_JUR="10";
IF &State="District of Columbia" THEN GEO_JUR="11";
IF &State="Florida" THEN GEO_JUR="12";
IF &State="Georgia" THEN GEO_JUR="13";
IF &State="Hawaii" THEN GEO_JUR="15";
IF &State="Idaho" THEN GEO_JUR="16";
IF &State="Illinois" THEN GEO_JUR="17";
IF &State="Illinios" THEN GEO_JUR="17";
IF &State="Indiana" THEN GEO_JUR="18";
IF &State="Iowa" THEN GEO_JUR="19";
IF &State="Kansas" THEN GEO_JUR="20";
IF &State="Kentucky" THEN GEO_JUR="21";
IF &State="Louisiana" THEN GEO_JUR="22";
IF &State="Maine" THEN GEO_JUR="23";
IF &State="Maryland" THEN GEO_JUR="24";
IF &State="Massachusetts" THEN GEO_JUR="25";
IF &State="Michigan" THEN GEO_JUR="26";
IF &State="Minnesota" THEN GEO_JUR="27";
IF &State="Mississippi" THEN GEO_JUR="28";
IF &State="Missouri" THEN GEO_JUR="29";
IF &State="Montana" THEN GEO_JUR="30";
IF &State="Nebraska" THEN GEO_JUR="31";
IF &State="Nevada" THEN GEO_JUR="32";
IF &State="New Hampshire" THEN GEO_JUR="33";
IF &State="New Jersey" THEN GEO_JUR="34";
IF &State="New Mexico" THEN GEO_JUR="35";
IF &State="New York" THEN GEO_JUR="36";
IF &State="North Carolina" THEN GEO_JUR="37";
IF &State="North Dakota" THEN GEO_JUR="38";
IF &State="Ohio" THEN GEO_JUR="39";
IF &State="Oklahoma" THEN GEO_JUR="40";
IF &State="Oregon" THEN GEO_JUR="41";
IF &State="Pennsylvania" THEN GEO_JUR="42";
IF &State="Puerto Rico" THEN GEO_JUR="72";
IF &State="Rhode Island" THEN GEO_JUR="44";
IF &State="South Carolina" THEN GEO_JUR="45";
IF &State="South Dakota" THEN GEO_JUR="46";
IF &State="Tennessee" THEN GEO_JUR="47";
IF &State="Texas" THEN GEO_JUR="48";
IF &State="United States" THEN GEO_JUR="N1";
IF &State="Utah" THEN GEO_JUR="49";
IF &State="Vermont" THEN GEO_JUR="50";
IF &State="Virginia" THEN GEO_JUR="51";
IF &State="Washington" THEN GEO_JUR="53";
IF &State="West Virginia" THEN GEO_JUR="54";
IF &State="Wisconsin" THEN GEO_JUR="55";
IF &State="Wyoming" THEN GEO_JUR="56";

IF &State="American Samoa" THEN GEO_JUR="60";
IF &State="Guam" THEN GEO_JUR="66";
IF &State="Northern Mariana Islands " THEN GEO_JUR="69";
IF &State="Republic of Palau" THEN GEO_JUR="70";
IF &State="U.S. Virgin Islands " THEN GEO_JUR="78";
IF &State="Virgin Islands " THEN GEO_JUR="78";
IF &State="N1" THEN GEO_JUR="N1";
run;
%Mend;

data GEOMACRO1;
set GEOMACRO;
?????
run;

6 REPLIES 6
Reeza
Super User
Please dont post the same question twice.
ybz12003
Rhodochrosite | Level 12

I didn't know it's the same tech support people,  I think if I post in the different place,  I could get different answer so that I could learn about the different tricks.   Besides, not all of the solutions are suitable for my situation.

ballardw
Super User

@ybz12003 wrote:

I didn't know it's the same tech support people,  I think if I post in the different place,  I could get different answer so that I could learn about the different tricks.   Besides, not all of the solutions are suitable for my situation.


 

Actually a majority of the help posts are volunteers, not tech support.

Also an additional issue is that a solution, once accepted, may not be found by someone searching an finding one post but not the other. Plus some communication issues with responding to the same questions in multiple posts or more entertaining answering a question posed in post in the other part of the thread.

Reeza
Super User

+1000 -> Actually a majority of the help posts are volunteers, not tech support.

Reeza
Super User

Also, on the same train of thought, please mark questions as answered when you have a solution. It doesn't look like any of your previous questions were marked as answered. 

ybz12003
Rhodochrosite | Level 12

Thanks for all of your kindness reply and volunteer.   I'm new here, don't too much about rules.  

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 1366 views
  • 3 likes
  • 3 in conversation