- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 02-27-2020 05:24 AM
(756 views)
I have two variables
one is named yr and is an integer e.g. 2017
and one called quarter taking values Q1, Q2, Q3 etc.
How can I produce a variable called Time which contains YearQuarter concatenated e.g. 2017Q1 etc?
I tried this:
rsubmit;
DATA dataset_1;
SET dataset_1;
Time=cat(yr, quarter);
RUN;
endrsubmit;
but it returns empty values
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Works fine?
data test;
yr=2017;
quarter='Q1';
time=cat(yr, quarter);
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Pleas provide more details as this code works fine
data dataset_1;
input yr quarter $;
Time=cat(yr, quarter);
datalines;
2017 Q1
2017 Q2
2017 Q3
;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can you post your reply with variables names insted of using datalines?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@ed_sas_member 's reply DOES have variable names. The datalines approach is used instead of SET statements to show you that the CAT functions works - you can compare the result to the original variables YEAR and QUARTER.
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------