BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

data have;
length ln Status $25. ;
input ln Status Month date9. ;
return;
datalines;
122 Current 01Nov2019
123 Current 30Nov2019
124 Due_030 01Dec2019
125 Due_030 31Dec2019
;run;

data have2;
set have;
format month mmyys7.;
run;

PROC TRANSPOSE data=have2 OUT=have3;
BY ln;
ID Month;
VAR Status /*'ASSESSED FEE VOLUME'n*/;
RUN;

I have hardcoded 4 values based on Month.  I then do a proc transpose and show 11/2019 and 12/2019.  I need to show these dates in a report.  How can  I account for future dates once the data is populated (ie 1/2020, 2/2020) and avoid the need to hardcode the dates each month??

2 REPLIES 2
ChrisNZ
Tourmaline | Level 20

Please format your code correctly, and use the letter case for legibility. You eyes are still hurting.

Unsure what you are trying to achieve, but his might help:

data HAVE;
  length LN STATUS $25. ;
  input LN STATUS MONTH date9. ;
  format MONTH mmyys7.;
datalines;
122 Current 01Nov2019
123 Current 30Nov2019
124 Due_030 01Dec2019
125 Due_030 31Dec2019
run;

proc transpose data=HAVE out=TRANS prefix=DT_;
  by LN;
  id MONTH;
  var STATUS /*'ASSESSED FEE VOLUME'n*/;
run;

proc print data=TRANS;
  var DT_: ;
run;

Obs DT_11_2019 DT_12_2019
1 Current  
2 Current  
3   Due_030
4   Due_030

 

Kurt_Bremser
Super User

What do you mean by "hardcode"? PROC TRANSPOSE will use the values provided in the dataset, so any addition there will be automatically included in the output.

Since you talk about a report, I suggest you look at PROC REPORT instead to create our intended result:

data have;
length ln Status $25. ;
input ln Status Month :date9.;
format month mmyys7.;
x = 1;
datalines;
122 Current 01Nov2019 
123 Current 30Nov2019 
124 Due_030 01Dec2019 
125 Due_030 31Dec2019 
;

proc report data=have;
column ln month,status dummyvar;
define ln / group;
define month / across;
define status / display;
define dummyvar / computed noprint;
compute dummyvar;
  dummyvar = 1;
endcomp;
run;

The dummyvar "trick" has to be used so PROC REPORT does not complain about a missing statistic, see https://support.sas.com/resources/papers/proceedings14/SAS388-2014.pdf 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 910 views
  • 0 likes
  • 3 in conversation