data cls;
attrib name $upcase. Sex $lowcase. ;
/* format name $upcase. sex $lowcase.; */
set sashelp.class;
run;
i want to try name in upcase and sex in lowcase using attrib and format statements
pls where i did wrong above code
You need to specify the Format Attribute the in the Attrib Statement.
Also, I don't think a Lowcase Format exists.
data cls;
attrib name format = $upcase.;
set sashelp.class;
run;
Maxim 1: Read the Documentation.
Maybe you were thinking of the LOWCASE function.
gender=lowcase(sex);
But agreeing with @Kurt_Bremser, you really should check the documentation on these types of questions before coming here, you will save yourself time in the long run. Help documentation is available by pressing F1 in SAS, or via the Internet. I have published this information before, and I provide it again.
Alphabetical list of all SAS PROCs
Alphabetical list of all SAS functions
Alphabetical list of all SAS statements
Alphabetical list of all SAS formats
Alphabetical list of all SAS informats
Might want to look at Proc Datasets and the MODIFY statement to change things like formats, labels or variable names in place. When you use a data step then every record is processed and might result in lots of not needed clock cycles. Proc Datasets modifies the data set in place by changing the data set header information.
Use of Proc Datasets is also less likely to accidentally add/remove variables or change values.
Consider a minor typo such as forgetting the E at the end of name:
data cls; attrib nam format=$upcase. ; /* format name $upcase. sex $lowcase.; */ set sashelp.class; run;
This will add a variable named Nam to the data set.
Note: I don't find any reference to a LOWCASE format. There is an Upcase but not Lowcase supplied by SAS.
If your organization has such installed then that's another story.
You would have to remember that just because the format is applied to a value that you still need to use the base value for referencing the value in code such as: "if name='Alice' then <do something>;"
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.