DATA MYDATA;
INPUT metai ketvirciai kiekis;
DATALINES;
2012 1 4
2012 2 8
2012 3 9
2012 4 12
2013 1 3
2013 2 5
2013 3 10
2013 4 13
;
Data formatas;
Set MYDATA;
eurai = compress(kiekis) ;
vienetai =cats('per'||' '|| substr(eurai,1,2)|| 'eur');
Proc print Data=formatas;
VAR Metai Ketvirciai vienetai;
Run;
Hello everyone, how to change number "vienetai" format from 4, 8, 9 ,12.... to 4.00 , 8.00 , 9.00 , 12.00....
To apply a format to a number use the PUT() function. It looks like you need the CATX() not the CATS() function.
data mydata;
input metai ketvirciai kiekis;
datalines;
2012 1 4
2012 2 8
2012 3 9
2012 4 12
2013 1 3
2013 2 5
2013 3 10
2013 4 13
;
data formatas;
set mydata;
length vienetai $20 ;
vienetai=catx(' ','per',put(kiekis,comma10.2),'eur');
run;
Obs metai ketvirciai kiekis vienetai 1 2012 1 4 per 4.00 eur 2 2012 2 8 per 8.00 eur 3 2012 3 9 per 9.00 eur 4 2012 4 12 per 12.00 eur 5 2013 1 3 per 3.00 eur 6 2013 2 5 per 5.00 eur 7 2013 3 10 per 10.00 eur 8 2013 4 13 per 13.00 eur
You wouldn't use CATS to change a number format.
You can simply assign a format to the numeric variable, such as
format eurai 8.2;
where the .2 indicates you want two digits after the decimal point.
But i need from both number sides write word's "per .... eur "
I need make like this
Is this what you are looking for?
Data formatas;
Set MYDATA;
length eurai $ 5. vienetai $ 20. ;
eurai = putn(kiekis, "5.2");
vienetai =cats('per'||' '|| eurai || 'eur');
run;
To apply a format to a number use the PUT() function. It looks like you need the CATX() not the CATS() function.
data mydata;
input metai ketvirciai kiekis;
datalines;
2012 1 4
2012 2 8
2012 3 9
2012 4 12
2013 1 3
2013 2 5
2013 3 10
2013 4 13
;
data formatas;
set mydata;
length vienetai $20 ;
vienetai=catx(' ','per',put(kiekis,comma10.2),'eur');
run;
Obs metai ketvirciai kiekis vienetai 1 2012 1 4 per 4.00 eur 2 2012 2 8 per 8.00 eur 3 2012 3 9 per 9.00 eur 4 2012 4 12 per 12.00 eur 5 2013 1 3 per 3.00 eur 6 2013 2 5 per 5.00 eur 7 2013 3 10 per 10.00 eur 8 2013 4 13 per 13.00 eur
Thank you. its works !!
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.