I am self learning SAS and am stuck in a very basic Issue.
Kindly refer to the code:
data work.empsal1; set work.empsal; if salary < 20000 then PAYBAND = "LOW" ; ELSE IF 20000 <= SALARY < 30000 THEN PAYBAND = "MEDIUM"; ELSE PAYBAND = "HIGH"; RUN;
The values in the PAYBAND column is appearing as 'LOW', 'MED', 'HIG'
How to fix It.
It is very basic issue but as I have no direct tutor I cannot solve it. Plz help.
after the SET statement, you need a LENGTH statement to specify the maximum length of the variable. If you don't it sets the length by the length of the first time the variable is assigned a value.
length payband $ 6;
after the SET statement, you need a LENGTH statement to specify the maximum length of the variable. If you don't it sets the length by the length of the first time the variable is assigned a value.
length payband $ 6;
@avijit_p wrote:
It is very basic issue but as I have no direct tutor I cannot solve it. Plz help.
People get direct tutors?
A very important part of SAS is the Format of variable. The format displays desired text and for almost all of the analysis procedures will use the formatted values for categories. The very fun part is that you can create formats as needed. That will allow you to create multiple displays or analysis from the same variable without having to create multiple variables as long as you only need one category set per procedure for a given variable.
Consider:
proc format library=work; value payband low - < 20000 = 'LOW' 20000 - < 30000 = 'MEDIUM' 30000 - HIGH = 'HIGH' ; value alpayband 0 - < 20000 = 'LOW' 20000 - < 30000 = 'MEDIUM' 30000 - < 50000 = 'Higher' 50000 - High = 'HIGHEST' ; run; proc freq data=work.empsal; tables salary; format salary payband.; run; proc freq data=work.empsal; tables salary; format salary altpayband.; run;
Thanks for the support.
The first SAS e-course is free and covers topics like this. There's also
video.sas.com -> How To> Analytics U
http://video.sas.com/#category/videos/sas-analytics-u
Lots of videos that cover these topics.
Thanks a lot.
The videos would of a great help.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.