- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I have a dataset where Amt columns are in form of values and i want output to look like when Flag is yes then format amount fields with dollar sign and Falg is N then with % sign
T3 = T1/T2
Test1
SPP | SLN | Amt1 | Amt2 | T1 | T2 | Flag |
650 | 300 | 20 | 53 | 15 | 24 | Y |
325 | 250 | 52 | 87 | 10 | 32 | N |
Output should look like
SPP | SLN | Amt1 | Amt2 | T3 | Flag |
650 | 300 | 20$ | 53$ | 15$/24$ | Y |
325 | 250 | 52% | 87% | 10%/32% | N
|
Can anyone please help
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is this what you are looking for?
No sure why you are doing this, so there might be a better solution
data have ;
infile cards ;
input amt1 amt2 t1 t2 flag $ ;
cards ;
20 53 15 24 Y
52 87 10 32 N
;
data want ;
length
amt1F $10
amt2F $10
T3 $100 ;
set have ;
if flag="Y" then
symbol="$" ;
else
symbol="%" ;
amt1F=trim(putn(amt1,"8."))!!symbol ;
amt2F=trim(putn(amt2,"8."))!!symbol ;
t3=trim(putn(t1,"8."))!!symbol!!"/"!!trim(left(putn(t2,"8.")))!!symbol ;
put amt1F= amt2F= t3= ;
run ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You want Amt1 and Amt2 to be numeric and T3 to be character, correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
So if flag = 'Y' you want to attach "$" to Amt1 and Amt2 and combine T1 and T2 and if flag = "N" you want to "%" instead of "$". Right?
You do want a report, correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is this what you are looking for?
No sure why you are doing this, so there might be a better solution
data have ;
infile cards ;
input amt1 amt2 t1 t2 flag $ ;
cards ;
20 53 15 24 Y
52 87 10 32 N
;
data want ;
length
amt1F $10
amt2F $10
T3 $100 ;
set have ;
if flag="Y" then
symbol="$" ;
else
symbol="%" ;
amt1F=trim(putn(amt1,"8."))!!symbol ;
amt2F=trim(putn(amt2,"8."))!!symbol ;
t3=trim(putn(t1,"8."))!!symbol!!"/"!!trim(left(putn(t2,"8.")))!!symbol ;
put amt1F= amt2F= t3= ;
run ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much for all help . This is right . I will apply same logic to my data and check . Will update .
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content