How to convert 2000to 2k in SAS dataset
Which function we have to use & also how to convert month number to month name using proc format and strip(put,...) Functions. help in getting this
@Dq1 wrote:
How to convert 2000to 2k in sasdataset
Please help us. Go back to your original post and edit it so that it has a meaningful title/subject. Since this is the SAS community, saying your subject is "Sas" is not helpful or meaningful.
You cannot convert 2000 to 2k, the first is a numeric value and the second is a character value. You could create a new variable that contains the text string "2K". A better solution, in my opinion: you could produce a FORMAT that changes the appearance to 2k.
proc format;
picture thous(round) low-high='000,009.9K' (prefix='$' mult=.01);
run;
data want;
set have;
format yourvariablename thous.;
run;
We help you, but you have to help us.
Go back to your original post and edit it so that it has a meaningful title/subject. Since this is the SAS community, saying your subject is "Sas" is not helpful or meaningful.
proc format;
picture thous(round) low-high='000,009.9K' (prefix='$' mult=.01);
run;
data a;
input name $ age sal;
format sal thous.;
cards;
Amir 23 4000
Sonu 34 7000
;
@Dq1 wrote:
It's not working ..
Make it work.
Please:
We help you, but you have to help us.
Go back to your original post and edit it so that it has a meaningful title/subject. Since this is the SAS community, saying your subject is "Sas" is not helpful or meaningful.
How should a value like 100 appear for that variable? 15345?
2000 to 2K is a single example. Coding is about providing general rules.
Same with month number to month name. Do you want the full name of a month? 3-letter abbreviation? something else?
See this example for your format for 2000 as 2K.
https://communities.sas.com/t5/SAS-Programming/Million-Format/td-p/440121
Regarding month number to name use MONNAME format which will format a SAS date (not month number) to the month name.
data example;
date = '01Jan2021'd;
demoName = put(date, monname3.);
run;
proc print data=example;
run;
proc print data=example;
format date monname3.;
run;
If you want to convert a month number to a date, I'd probably create a fake date out of it using the MDY() function and use the PUT() function.
data example2;
monthNumber = 2;
monthName = put(mdy(monthNumber, 1, 2021), monname3.);
run;
proc print data=example2;
run;
@Dq1 wrote:
How to convert 2000to 2k in SAS dataset
Which function we have to use & also how to convert month number to month name using proc format and strip(put,...) Functions. help in getting this
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.