BookmarkSubscribeRSS Feed
jiantos
Fluorite | Level 6
Hi everyone,
I am new to SAS and just learning the programming language.
I have one datafile called intervention_dataset, that has assessments completed from 2015-2023 (n=1925), and I am looking to match a pair of assessment outcomes (from different children) between 2015-2020 (n=1225), and 2020-2023 (n= 700) on key variables.
Code:
Data intervention_dataset
Proc format;
value mydategroup
'06Mar2015'd - 16Mar2020'd='2015-2020'
'17mar2020'd - '07Mar2023'd='2020-2023'
;
run;

Proc freq data=intervention_dataset;
tables (Var1 Var2 Var3) *complete_d / chisq;
format complete_d mydategroup.;
run;
When I use this code, I receive a contingency table with the MM/DD/YYYY, as opposed to a composite of all outcomes within the restricted dates (see screenshot). No warning error in the LOG.
 
I cannot share my data due to ethical restrictions, but do you have any suggestions? Thank you.
1 REPLY 1
Tom
Super User Tom
Super User

Fix the error in the code so that the PROC FORMAT step will run and then see if it works.

 

Your existing code is trying to overwrite intervention_dataset and create two other datasets named PROC and FORMAT.  But it should not run since your assignment statement is missing operators between the values after the equal sign.  And your expressions have unbalanced quotes. So your dataset was unchanged the format was not created.

 

1886  data intervention_dataset proc format;
1887    value mydategroup
        -----
        180
1888      '06Mar2015'd - 16Mar2020'd='2015-2020'
                                  ----         ------
                                  49           49
1889      '17mar2020'd - '07Mar2023'd='2020-2023'
                    ------         ----
                    49             49
ERROR 180-322: Statement is not valid or it is used out of proper order.

NOTE 49-169: The meaning of an identifier after a quoted string might change
             in a future SAS release.  Inserting white space between a
             quoted string and the succeeding identifier is recommended.

1890    ;
1891  run;

 

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
  • 1 reply
  • 703 views
  • 0 likes
  • 2 in conversation