What will happen if there are 500 states? Write 500 "if ... else ..." statements?
It is not a good to do in this hard coding way. If these "if" statements are necessary are necessary in the code, then the best way is to let SAS generate these codes with PUT statement.
An example is given. the following data set i is from 1 to 10, and the corresponding x and y value are given. suppose I wanna get the x and y by the value of i. The method of using SAS to generate the "if ... else ..." statement is:
data a;
do i = 1 to 10;
x = i + 5;
y = i * 3;
output;
end;
run;
data _null_;
set a end = last;
if _n_ = 1 then put / "if i = " i "then x =
" x "and y = " y ";";
else put /"else if i
= " i " then x = " x "and y = " y ";";
if last then put /"else x =
" x "and y = " y ";";
run;
The generated code is like:
if i = 1 then x = 6 and y = 3 ;
else if i = 2 then x = 7 and y = 6 ;
else if i = 3 then x = 8 and y = 9 ;
else if i = 4 then x = 9 and y = 12 ;
else if i = 5 then x = 10 and y = 15 ;
else if i = 6 then x = 11 and y = 18 ;
else if i = 7 then x = 12 and y = 21 ;
else if i = 8 then x = 13 and y = 24 ;
else if i = 9 then x = 14 and y = 27 ;
else if i = 10 then x = 15 and y = 30 ;
else x = 15 and y = 30 ;
So you don't need to hard code these in your script.
By the way, the best way to do this is not by the "if ... else ..." statements. The best way should use FORMAT in sas.
Another way is to use PROC SQL to join to get the corresponding value.
Is there a similar statement in regular SAS macro or data step to Proc Sql: into?
ReplyDeleteBase SAS training in Chennai
Datawarehousing training in Chennai
Informatica training in Chennai
Hadoop training in Chennai
I cant wait to check out some of these blogs! I’ve really wanted to start learning more about cars and auto repairs lately and I think this will help a lot. I think it can save my family some money if we knew how to do some repairs at home.! Thanks again for all the options.
ReplyDeletebike spa services in mumbai
house cleaning services in mumbai
car wash services in mumbai
car spa at doorstep in mumbai
Thanks for appreciating. Really means and inspires a lot to hear from you guys.I have bookmarked it and I am looking forward to reading new articles. Keep up the good work..Believe me, This is very helpful for me.
ReplyDeleteHome Spa Services in Mumbai
Somebody necessarily help to make severely posts I might state. This is the first time I frequented your website page and to this point? I surprised with the research you made to create this particular post extraordinary. Well done admin..
ReplyDeleteBack to original
Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.
ReplyDeleteSelenium Training in Chennai
This blog is having the general information. Got a creative work and this is very different one.We have to develop our creativity mind.This blog helps for this. Thank you for this blog. This is very interesting and useful.
ReplyDeletedigital marketing company in india
This was so useful and informative. The article helped me to learn something new.
ReplyDeleteAndroid Training in Chennai
ReplyDeleteIts very useful to me. Wonderful blog.. Thanks for sharing informative Post.
Installment loans
Payday loans
Title loans
ReplyDeleteشركة نقل اثاث بالدمام تقدم خدمات لا حصر لها رائعة لتلبية طلبات العميل وتحقيق كل ما يتمناه في خدمات نقل العفش بالدمام فثقتنا في اعمالنا جيدة قد وضعتنا كخبراء داخل مجال نقل الاثاث حيث يتم التشاور مع حقيبة مختلطة من داخل شركة نقل عفش بالدمام عن اختيار المواد الخاصة بك والمواد أو الأشياء من على عتبة منزلك لتصل جميع ممتلكاتك بأمان إلى المكان الذي ترغب فيه
شركة نقل الاثاث بجدة لدينا ميل الي التفكير في إعطاء نوع من الإدارات لدي شركة نقل اثاث بجدة التي تطوير انفسهم ومتابعة كل ما هو حديث في عالم نقل الاثاث المنزلي والبحث عن الطرق الحديثة التي تؤدي الي انجاز المهمة بكل سهولة والتي تترك نجاح باهر يمكن أن يساعد على ارضاء نفسية عملائنا.لدينا الميل في شركة نقل عفش بجدة إلى أن يشار جيدا إلى السيارات الحديثة التي نمتلكها علي انها ذات كفاءة عالية كما نمتلك عمال تنزيل علي اعلي مستوي كما يوجد لدينا في خدمة نقل عفش بجدة
فنين فك وتركيب لديهم القدرة الكافية علي التعامل مع جميع انواع الاثاث كما اننا نمتاز باننا نمتلك المغلفون الذين يقومون بتغليف جميع الاثاث المنزلي للحفاظ عليه من الغبار والتكسير كل هذه العوامل التي تقدمها شركتنا نتيجة للمعيار والتنمية والعقل
شركة نقل الاثاث بمكةتكتشف مجموعتنا الخاصة في فريق شركة نقل اثاث بمكة في خدمتك في أي وقت من اليوم وأنها مستعدة للبقاء طيلة الوقت لمساعدتك في نقل اثاث منزلك سواء كان بيتك كبير او صغير قهذه ميزة الشركات الكبيرة التي تقدم الخدمات المتميزة فنحن نأمل دائما لإعطاء أفضل انطباع من تجربة نقل ممتازة. يتم اتخاذ كل خطوة الرعاية من قبل فريقنا والتعامل مع أفضل طريقة ممكنة. لدينا في شركة نقل عفش بمكة المتخصصين هم أيضا على استعداد للرد على الاحتياجات الفورية لعملائنا الكرام.
مستودعات تخزين الاثاث بالرياضالتعبئة والتغليف واحدة من أكثر المعترف بها في خدمة نقل وتخزين الاثاث بالرياض فخدمة التعبئة والتغليف لدي شركة تخزين اثاث بالرياض يمكن أن يحصل على انتباه الكثير من العملاء وهذا يرجع ببساطة إلى أننا نواصل الوفاء بطلباتهم. كما قمنا بتطوير وواصلنا تقديم أفضل الخدمات التي تحافظ علي ممتلكتهم في مستودعات تخزين العفش التي تكمل في الحفاظ علي الأموال المدفوعة في ممتلكتهم لحين الرجوع اليها مرة أخري
شركة تخزين اثاث
الشيء المثير للإعجاب بالنسبة الينا في شركة تخزين عفش بالرياض هو أن فريقنا على استعداد لخدمتك في أي وقت من اليوم لطالما كنت بحاجة لدينا فنحن نواصل إقناع عملائنا التأمين علي جميع العناصر الخاصة بهم. هذا هو السبب الرئيسي لماذا بقينا على أنها
Thank you for this great article which conveyed a good information.keep more updates.
ReplyDeleteSEO Company in India
SEO Services in India
SEO Companies in India
SEO Company India
SEO Services India
excellent IT coaching center in chennai PHP training center in chennai
ReplyDeleteThis comment has been removed by the author.
ReplyDeletewonderful post its very useful to me...
ReplyDeleteJava Training Institute in Chennai
ReplyDeleteThank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
bmc software vendors